`gulp.watch` blocking execution of `dotnet run`

Question: I'm executing gulp.watch as part of a precompile script in a .NET Core project. When executing dotnet run the gulp.watch call seems to block the thread, so that the application won't start at all.
How can I tell gulp.watch to return the handle to the thread?
I have created a minimum working example to reproduce the problem using dotnet new and installing gulp via npm.
This is my gulpfile.js:
var gulp = require('gulp');

gulp.task('copy', () => {
    gulp.src("watch_src/foo.txt")
      .pipe(gulp.dest("watch_dst/"));
});

gulp.task('watch', () => {
    var watcher = gulp.watch("watch_src/foo.txt", ['copy']);
    watcher.on('change', function(){
        console.log('foo.txt changed!');
    });
});

gulp.task('default', ['watch']);

My Program.cs file looks like:
using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

My project.json file looks like:
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      },
      "imports": "dnxcore50"
    }
  },
  "scripts": {
    "precompile": "gulp"
  }
}

Executing dotnet run will execute the precompile script and changes to foo.txt are reflected by the event handler on the console. But the Main method that should print Hello World! does not get executed:
c:\Temp\src\gulptest>dotnet run
Compiling gulptest for .NETCoreApp,Version=v1.0
[17:03:48] Using gulpfile c:\Temp\src\gulptest\gulpfile.js
[17:03:48] Starting 'watch'...
[17:03:48] Finished 'watch' after 11 ms
[17:03:48] Starting 'default'...
[17:03:48] Finished 'default' after 43 ╬╝s
foo.txt changed!
[17:04:15] Starting 'copy'...
[17:04:15] Finished 'copy' after 34 ms

Comment: I've also tried to use the `gulp-watch` plugin, but it behaves the same.
Comment: did you finally find the answer? I would be interested to know it. Thanks
Comment: No. Unfortunately it seems that either no one else has this problem or that they solved it in another way. I have also tried to get in contact with the gulp community [here](https://gitter.im/gulpjs/gulp) but no luck.
Comment: Damn I was hopping you give me the answer. I really want this. I just posted a [tweet](https://twitter.com/Koenigsbier/status/788240740258164736). If you have an account, please RT. Hope the community will see it...
Answer: I am using vs code and I've met the question as you too
In the project.json,you have the section:
"scripts": {
    "precompile": "gulp"
  }

which will stuck the dotnet run
Following these steps If you want to launch dotnet run and gulp watch
Step1: Define a new task in task.json file:
 {
            "type": "shell",
            "command": "gulp watch",
            "problemMatcher": [],
            "label": "gulp-watch"
 }

Step2: Add a new launch  configuration in launch.json:
  {

            "name": "gulp-watch",
            "preLaunchTask": "gulp-watch",
            "request": "launch",
            "type": "node"
  },

Step3: Add compound configuration in the launch.json:
 "compounds": [{
        "name": ".Net+gulp",
        "configurations": [
            "gulp-watch",
            ".NET Core Launch (web)"
        ]
    }],

For more detail,please refer to this link https://code.visualstudio.com/docs/editor/debugging
Answer: The main method in ASP.NET core should look like -
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();

The one you are showing above is pure console application and gulp is not required for it.


Inductive proof for the inequality

Question: I would prove that $n^2<2^{n+1}$ for all natural numbers by induction proof. How ?
Comment: What are your ideas? What have you tried, where did you get stuck?
Comment: I'm going to prove that $\forall n\in\mathbb{N},\ 2n+1<2^{n+1}$. How can I do this?
Answer: It's true for $n=1$ by direct calculation. Suppose it is true for $n$. Then
$$
(n+1)^2=n^2+2n+1<2^n+2n+1
$$
where the last step uses the inductive hypothesis. Thus you need to show that
$$
2^n+2n+1<2^{n+1}=2\cdot2^n.
$$
This is only true when $2n+1<2^n$, which unfortunately doesn't hold for $n=1,2$. So you'll have to check the base case for $n=2$ as well, but then you're done.
Comment: My inequality is correct. Is there any other way for this induction?
Comment: There's really only one way to do it. What I'm saying is that the inductive step only kicks in once you prove the cases of $n=1,2$ explicitly.
Comment: @IanColey: Your proof is flawless, but I point out only "$\leq$"needs to be shown in the second displayed equation since you already have "$<$" in the first (so together you still have strict inequality), right?
Comment: That's true. All the same, $\leq$ doesn't kick in until $n>2$ as well.

Inductive proof for the inequality


How to transfer data between C++ project and DLL in C++ with CUDA in the correct way?

Question: I have a C++ project which uses DLL in C++ with CUDA.
Now I'm passing 2 pointers from the main project to DLL. Inside DLL, the arrays will be copy to device memory. Some calculation will be done with them. And then, the arrays will be copy back to host.
I heard that the data transfering will be better with data overlap method. But how can I do it in this case? The copy function cudaMemcpyAsync requires pinned memory to be asynchronous and the passed pointers are not, right?
I'm using the temporary solution is to use memcpy to copy passed arrays to pinned arrays. Then, I use streams to overlap data. After that, use memcpy again to copy from pinned memory arrays to passed arrays. And the CPU stuff is clearly not a good way here, I think.
And can we do something like passing pinned memory arrays from main project to DLL when both are with CUDA?
Many thanks in advance.
Comment: @sgar91 please post your recommendation to use `cudaHostRegister()` as an answer. That way Harry can accept it and people will know the question is answered.
Comment: You can convert simple host memory to pinned memory using [`cudaHostRegister`](http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g36b9fe28f547f28d23742e8c7cd18141).
Comment: This seems to be the one, I'll check. Thanks man.
Answer: The memory allocated by standard C/C++ allocators i.e. malloc and new can be converted to page locked memory by using the CUDA Runtime function cudaHostRegister, which can be used to overlap asynchronous memory copies b/w host and device. Be advised; don't forget to unpin the memory which has been pinned using the mentioned function. Use cudaHostUnregister to unpin the memory. If memory is not unpinned, undesired results may be produced. e.g. a function may try to pin the memory which has already been pinned. or pinned memory may be freed using free or delete which is undefined behavior.


How to hide an empty view block when using a contextual filter and NO file fields?

Question: I'm trying to figure out how to hide a view block when it has no rows. Though this questions is similar, it's not the same. In my situation I am also using a contextual filter but have no file fields so the answer in that question doesn't apply.
I've tried global: null as a second contextual filter but still the block shows with just the title.
Can anyone help me solve this issue.
Many thanks for any help.
Answer: Add  another filter it's not important which field , as example if you have Content:title ( or any field you have in fields row) and  set filter is it's not empty.
The mechanism is simple, contextual filter cause view not consider as empty even thought there is no any row, and when you add a filter on a field that not exists it cause view considered as empty. So only add one of your view field to  filter and  check if it is not empty
Comment: @dibs you 're welcome, follow me on twitter, sometimes I need a hug ;)
Answer: I tried various methods suggested in various places, including this one from @zhilevan, but the only way I could get it to work was to remove the title from the block and add it in as a header to the block.


How to specify Port Range in 'haproxy' frontend?

Question: I have haproxy working, but one port per line is specified.
frontend localhost
    bind *:8443
    bind *:443
    bind *:80
    bind *:8080

Say, if I want to specify port range, like 30000-35000, how do I do that? I don't want to add 5K lines.
Comment: NM... I think I got solution. bind []: [, ...]
Answer: NM ... I got answer
bind [<address>]:<port_range> [, ...]
bind *:2000-2100

Particular care must be taken against port ranges, because every  couple consumes one socket (= a file descriptor), so it's easy to consume lots of descriptors with a simple range, and to run out of sockets


Vim OmniCppComplete on vectors of pointers

Question: I might have done something wrong in the set up but is OmniCppComplete supposed to provide the members/functions of classes when doing this?
vectorofpointers[0]->

At the moment all I get when trying that are things relating to the vector class itself, which obviously isn't very useful. I think it might have been working before I tagged /usr/include/ but I could be wrong.
Also, is it possible to disable the preview window? I find it just clutters up my workspace. And since I enabled ShowPrototypeInAbbr I don't really need it.
Thanks,
Alex
Answer: I do not think it is possible to get proper code completion on the objects that are included in the vector, but someone please correct me if I am mistaken.
To disable the preview window, make sure to not set preview for the the completeopt option, type :help completeopt in Vim for more information.
Comment: Thanks, I must have been delusional when I thought I saw it before.
Answer: We finally have sane code completion for C++ in Vim using GCCSense. With GCCSense it is possible to autocomplete on the contents of a vector.


multiple download folders using Selenium Webdriver?

Question: I'm using the Selenium webdriver (in Python) to automate the donwloading of thousands of files. I want the files to be saved in different folders. The following code works, but it requires quitting and re-starting the webdriver multiple times, which slows down the process:
some_list = ["item1", "item2", "item3"] # over 300 items on the actual code
for item in some_list:
    download_folder = "/Users/myusername/Desktop/" + item
    os.makedirs(download_folder)
    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    fp.set_preference("browser.download.dir", download_folder)
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain")
    browser = webdriver.Firefox(firefox_profile = fp)

    # a bunch of code that accesses the site and downloads the files

    browser.close()
    browser.quit()

So, at every iteration I have to quit the webdriver and re-start it, which is pretty innefficient. Is there a better way to do this? Apparently we can't change the Firefox profile after the webdriver is instantiated (see this and this previous questions), but perhaps there is some alternative I'm missing?
(Mac OS X 10.6.8, Python 2.7.5, Selenium 2.2.0)
Comment: Would it work to move the files using plain old Java?
Comment: Hhmm, I haven't tried it -- I'm a newbie to programming and I only know some Python.
Comment: I download all files to specified location and between each downloads I use rename method from os module to move and rename files.
Answer: No, I don't think you can do it.
Option one: specify different default directories for one FirefoxProfile
You can't. In my opinion, this is the issue with Firefox, not Selenium. However, this Firefox limitation looks like the correct design to me. browser.download.dir is the default download destination, if it allows multiple directories, then that's not "default" anymore.
Option two: switch multiple FirefoxProfile for one driver instance
If not doing it in Firefox, can FirefoxProfile be switched for same driver instance? As far as I know, the answer is no. (You have already done some research on this)
Option three: use normal non-Selenium way to do the downloading
If you want to avoid using this auto-downloading approach and do it the normal way (like Auto-it etc.), then it falls in the category of "How To Download Files With Selenium And Why You Shouldn't". But in this case, your code can be simplified.
some_list = ["item1", "item2", "item3"] # over 300 items on the actual code
for item in some_list:
    download_folder = "/Users/myusername/Desktop/" + item
    some_way_magically_do_the_downloading(download_folder)

Comment: Thanks. I'll try and learn some java and then see if I can understand the code in "How to Download..." and how I might translate it to Python.


Solving for different variables

Question: I've been trying to solve this for n, but I haven't been successful.
$$S= n[2a+(n-1)d]$$
I've started by multiplying $(n-1)d$ since it is within parenthesis.
Following, I've added it to $2a$ which is inside the square bracket.
Finally, I've multiply by the n which is outside the square bracket.
I got to this:
                              $$S= 2na + n^2d - nd$$
I have tried factoring it. However, I still wasn't able to solve it for "$n$".
Any suggestions ?
Comment: Is $S$ a real number? Subtracting $S$ from both sides gives us a quadratic in $n$.
Answer: Hint: Your equation is equivalent to $$S=2an+(n^2-n)d$$
$$0=n^2d-nd+2an-S$$
$$0=n^2-n+\frac{2a}{d}n-\frac{S}{d}$$
$$0=n^2+n\left(\frac{2a}{d}-1\right)-\frac{S}{d}$$ for $d\neq 0$ now use the quadratic formula.

Solving for different variables


Cannot reinstall iMessage Extension after explicitly uninstalling

Question: I have an iMessage extension included in my main app. Added to the project like so:

And then chose my app Xcode Project from the "Embed in Application" dropdown (I already did this step, the screenshot was taken afterwards to help explain my question):

I pushed a new build to the iTunes Connect and TestFlight. Another tester and myself than explicitly deleted the iMessage extension (NOT the main app) like so:

Now the tester and myself cannot get the embedded iMessage Extension to reinstall. We have explicitly deleted the main app and reinstalled and that did not reinstall the embedded iMessage extension.
I even incremented the build number (not the version number) and pushed another build to TestFlight to try and trigger and fresh reinstall.
I am going to increment the version number of my app now (even though there are no changes) to see if that will get the iMessage Extension to reinstall.
Any other suggestions?
Answer: It looks the an iPhone will remember an explicit decision to uninstall an iMessage Extension and though a new install of the main app with an embedded iMessage Extension will install the extension again it is now off by default and has to be explicitly reenabled:


Find $\sum_{n=1}^{\infty} n\left(2n-1\right)x^{2n}$

Question:
Question: Find $$\sum_{n=1}^{\infty} n\left(2n-1\right)x^{2n}.$$

My Approach:$$
\lim_{n\rightarrow\infty} |n\left(2n-1\right)|^{\frac{1}{n}} =1 \Longrightarrow \text{Radius
of convergence} = 1.
$$
I don't know how to find the sum. Any Hint or help will be highly appreciated.
I Solved It,Thanks To Przemysław Scherwentke
$\sum_{n=1}^{k}$$x^{2n}$=$\frac{x^{2}\left[1-\left(x^{2}\right)^{k}\right]}{1-x}$
$\Rightarrow$$\sum_{n=1}^{\infty}$$x^{2n}$=$\frac{x^{2}}{1-x}$
Differentiating twice we get the required result .
Answer: HINT: $(x^{2n})''=2n\cdot(2n-1)x^{2n-2}$
Comment: Does the method use Abel's Theorem?
Comment: @MohanSharma The method is: differentiation of power series.
Comment: OK I got that, I think
Answer: Take $f(x)=\sum_{n=1}^{\infty}n(2n-1)x^{2n}$ therefore:$$g(x)=\int \frac{f(x)}{x^2}dx=C_1+\sum_{n=1}^{\infty}nx^{2n-1}\\g_1(x)=\sum_{n=1}^{\infty}nx^{2n-1}\\h(x)=\int \frac{g_1(x)}{x}dx^2=C_2+\sum_{n=1}^{\infty}x^{2n}=\frac{1}{1-x^2}-1+C_2$$Now by successive differentiation we obtain:$$g_1(x)=x\frac{dh(x)}{d(x^2)}=\frac{x}{(1-x^2)^2}\to g(x)=\frac{x}{(1-x^2)^2}+C_1$$and $$f(x)=x^2\frac{dg}{dx}=\frac{-3x^6+2x^4+x^2}{x^4-2x^2+1}$$ and finally:$$\sum_{n=1}^{\infty}n(2n-1)x^{2n}=x^2\frac{1+3x^2}{1-x^2}$$


Troubleshooting SQL Connectivity on Azure

Question: I am setting up a virtual server network on Azure.
1) Active Dir - Windows Server 2012 Datacenter
2) SQL Server - Windows Server 2012 Datacenter
3) App Server - Windows Server 2008 R2 Datacenter
4) App Server - Windows Server 2012 Datacenter
All servers visible in Active Directory & All servers have IP's
SQL Server firewall setup in/out rules for sql default port 1433
App Servers can ping the SQL Server using machine name and IP
I have confirmed SQL Server is listening on port 1433 using Port Query utility.
To test SQL Connectivity I create a connection.udl file on each app server and double click it to open the UI.
I then configure it to connect to the SQL server using machine name with the MS OLE DB Provider for SQL Server and click the "Test the Connection" button  which returns error:
<code>---------------------------
Microsoft Data Link Error
---------------------------
Test connection failed because of an error in initializing provider. [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found.
---------------------------
OK
---------------------------
</code>
I then change the configuration to use the IP address of the SQL Server instead of the machine name and the connection succeeds.
What settings should be altered on any or all of these machines to be sure the connection succeeds using the machine name?  This is very odd considering the app servers can ping the sql server using IP or machine name.
Comment: Update.  If I enter the fully qualified name of the server then it works.  I am not sure if this is by design but it works.
Comment: Soon after; that same configuration using the fully qualified name of the sql server began failing again.
Comment: seems like some intermittent issue... very difficult to pinpoint
Answer: The issue here is that SQL Server 2012 now REQUIRES you specify the port even if the default 1433 is used.  Specifying the <>,<> is required to make the connection work properly.


Rebend Violin bow

Question: According to this answer, one can 'reheat and rebend' a violin bow. I have an old bow (poor-quality, it is weighted badly and needs rehairing) that is very slack and I'm guessing needs rebending.
I don't really want to take it to a luthier, since it's not really worth it, and I can only find tutorials for rebending warped bows (that twist to the side, which mine does not)
How can I rebend my bow?
Answer: Don't guess.  Slack has nothing to do with bow-bend and everything to do with the age of the hair or even the skill with which it was last rehaired.  If it's really not weighted the way you want, why bother with it at all in the first place?
How do you know what it's worth if you haven't taken it to a luthier?
I can guarantee that  any attempt on your part to rebend in any axis will lead to disaster.  My recommendation is that you bring it to a luthier or reputable string instrument store and either get it repaired or sell it to them.

Rebend Violin bow


What is the difference between the '[]' property and the '@each' property in ember.js?

Question: I've noticed that the enumerable mixin has computed properties that depends on the '[]' property, while ember arrays also have the '@each' property.
What is the difference between depending on '[]' and '@each'?
My vague understanding (correct me if I'm wrong) is that '[]' is triggered when the array content is replaced. But is this different than depending on the property itself?
Consider the the following class:
C = Ember.Object.extend({
  things: null,
  watcher1: (function() {
    console.log('watcher1')
  }).observes('things.[]'),
  watcher2: (function() {
    console.log('watcher2')
  }).observes('things.@each')
});

And I create an instance as follows:
c = C.create({things: Ember.A(['a', 'b'])});

The following:
c.get('things').replace(0, 1, ['z'])

triggers watcher1 and watcher2
And the following:
c.get('things').setObjects(['1', '2'])

also triggers watcher1 and watcher2
As does:
c.get('things').addObject('v')

So is there any difference? When should we use one vs. the other?
Thanks!
Kevin
Answer: Use @each if you need to observe properties of array elements
@each supports observing properties of the elements inside the array. For example, people.@each.name. The bracket notation does not support this. Here is a jsbin demo.
@each is a property of Array instances that returns an EachProxy instance that handles the delegation. On the other hand, [] simply returns this.
Use [] if you need it to work on non-Array enumerables
According to the ember changelog, the bracket notation was made defunct in favor of @each in ember 0.9.4, but then re-enabled in 0.9.8. The commit that re-enables it indicates that [] can be used for non-Array enumerables such as Ember.Set instances. jsbin demo.
Comment: The current official documentation –  http://emberjs.com/api/classes/Ember.Array.html#property__each makes it  quite clear when to use which.


Microsoft NPS 2012 R2 - Can't perform authentication from Cisco ASA with PAP

Question: I am trying to setup a Cisco ASA (version 9.1(7)6) to authenticate against a Microsoft Network Policy Server 2012 R2.
The ASA is able to communicate with the NPS server, however the test aaa-server command returns AAA Failure. Checking the security event log on the NPS server shows that authentication is failing because The user attempted to use an authentication method that is not enabled in the matching network policy. and Authentication Type: PAP.
What I dont understand is that Unencrypted authentication (PAP, SPAP) is enabled for the network policy. The server is on a fresh install of Windows and there is only a single network policy outside of the defaults. The event log entry does show it is matching my single (non-default) network policy. There do not appear to be any other relevant event log entires.
There only seems to be a problem with PAP authentication, as I am able to login via my VPN connection by authenticating against the NPS by using MSCHAPv2. As a note, the test aaa-server command only supports PAP authentication.
Network Policy Authentication Methods
Event Log Entry
Answer: In NPS, make sure PAP is enabled on the Connection Request Policy in addition to the Network Policy.  I had a similar problem authenticating Cisco Prime Infrastructure using PAP, so maybe my solution will be applicable to you as well.


ITMS-90339: Deprecated Info.plist Key

Question: I sent a new build of an app to App Store Connect and received the following warning :
ITMS-90339: Deprecated Info.plist Key - The Info.plist contains a key 'UIApplicationExitsOnSuspend' in bundle xxx that will soon be unsupported. Remove the key, rebuild your app and resubmit.
I was still able to continue with publishing the new version but this warning got me worried.
Comment: Even after removing the key UIApplicationExitsOnSuspend from Info.plist, I am still getting this error. It says the key is still available. Can you please let me know if i am missing anything?
Answer: This was fixed in yesterdays update so if you send a new build that plist entry will no longer be there.
Answer: My app was removed from sales so not available on App Store. I made the app available and everything is good

ITMS-90339: Deprecated Info.plist Key


Impedir que classes modifiquem o estado de objetos

Question: Como impedir classes de modificar o estado de objetos de uma classe, ambos
Dentro de pacotes iguais e separados?
Assumindo que exista um pattern para projetar uma java class design que possa ou mesmo afete o estado dos objetos.
Comment: @IgorVenturelli, isso mesmo! No caso do Design pattern Observer se não me engano monitora o status de um objeto. Então, a forma que projetamos uma classe afeta o comportamento dos objetos.
Comment: A pergunta tem a tag design pattern. Você quer saber se tem algum pattern para isso?
Answer: Você deve criar classes imutáveis, onde o estado do objeto não pode ser alterado após a sua criação.
String é um exemplo de classe imutável, dentre tantos outros.
public final class Person {

     private final String name;
     private final int age;
     private final Collection<String> friends;

     public Person(String name, int age, Collection<String> friends) {
         this.name = name;
         this.age = age;
         this.friends = new ArrayList(friends);
     }

     public String getName() {
         return this.name;
     }

     public int getAge() {
         return this.age;
     }

     public Collection<String> getFriends() {
         return Collections.unmodifiableCollection(this.friends);
     }
}

Atributos private e final e sem métodos set.
Um ponto importante adicionado neste exemplo é o uso de coleções imutáveis.
Baseado nesta resposta.
Answer: Isso são objetos imutáveis onde depois de criado, o objeto não tem como alterar seu estado interno, e isso é obtido através de privação de formas de definição de atributos como por exemplo métodos acessores como o setX, outra convenção é deixar os atributos como final visto que não serão alterados.
E no caso de Composições deve-se ter uma forma de só haver acesso de leitura à essas instancias para essa classe e somente a classe externa podendo acessa-las .
Outra pratica é que se houver métodos que modifiquem atributos estes retornem um novo objeto criado.. Usando os atributos da atual instancia, e assim sempre gerando um novo objeto..
Então ou privar modificação dos atributos ou se puderem ser alterados retornar um novo objeto .


Showing $\int_0^1 x(1-x)^{2t} \mathrm{d}x$ concentrates around $\frac{1}{2t}$

Question: Suppose we have the following integral for $t>0$
$$f(t)=\int_0^1 x(1-x)^{2t} \mathrm{d}x$$
I'm interested in approximating it by integrating over a smaller interval $(a,b)$
$$f(t)\approx \int_a^b x(1-x)^{2t} \mathrm{d}x$$
Where $a$ is chosen so that the mass discarded on the left is at most $0.005 f(t)$, and $b$ is chosen so that the mass discarded on the right is at most $0.005 f(t)$.
In numerical simulations, $a$ and $b$ decay in proportion to $1/t$, what is the easiest way of showing this?

Notebook
Answer: Starting from @Ace's answer, you want to find, for a given value of $t$, the zero of function
$$f(a)=(1-a)^{2 t+1}\, (a(2 t+1)+1)-\frac{199}{200}=0$$ and we know that $a\ll 1$.
This being a polynomial of degree $2(t+1)$ in $a$, the only hope is approximation.
Expand $f(a)$ as a Taylor series around $a=0$ (say to $O(a^4)$) and then power series reversion to obtain
$$a=\frac{\sqrt{f(a)+\frac{1}{200}}}{\sqrt{(t+1) (2 t+1)}}+\frac{2 \left(f(a)+\frac{1}{200}\right) t}{3 (t+1) (2 t+1)}+\frac{\left(f(a)+\frac{1}{200}\right)^{3/2} t (22 t+9)}{36 ((t+1) (2 t+1))^{3/2}}+\cdots$$
Now, remember that we need $f(a)=0$; so, the estimate of $a$.
$$a\sim \frac{t \left(14422 \sqrt{2} t+480 \sqrt{(t+1) (2 t+1)}+21609
   \sqrt{2}\right)+7200 \sqrt{2}}{144000 ((t+1) (2 t+1))^{3/2}}$$ which seems to be acceptable
$$\left(
\begin{array}{ccc}
t & \text{approximation} & \text{solution} \\
  5 & 0.00896731 &  0.00896788 \\
 10 & 0.00480313 &  0.00480347 \\
 15 & 0.00328033 &  0.00328058 \\
 20 & 0.00249073 &  0.00249092 \\
 25 & 0.00200753 &  0.00200768 \\
 30 & 0.00168135 &  0.00168148 \\
 35 & 0.00144635 &  0.00144647 \\
 40 & 0.00126899 &  0.00126909 \\
 45 & 0.00113038 &  0.00113047 \\
 50 & 0.00101906 &  0.00101914 \\
\end{array}
\right)$$
For very large values of $t$, expanding again the estimate
$$a \sim \frac{7451}{144000 t}-\frac{2569}{64000
   t^2}+O\left(\frac{1}{t^3}\right)$$ which is "not far" from $\frac 1{20\,t}$
Edit
Since in comments, you mention Lambert function, you are looking for the inverse of
$$2t+1=-\frac 1 a +\frac 1{\log(1-a)}W_{-1}\left(\frac {199}{200}\frac{\log (1-a)}{a}(1-a)^{\frac{1}{a}}\right)$$ Limiting the expansion to first order (and it is a good approximation)
$$a \sim \frac{W_{-1}\left(-\frac{199}{200 e}\right)+1}{-(2t+1)+\frac{1}{2}
   W_{-1}\left(-\frac{199}{200 e}\right)}$$
Making the numbers rational
$$a \sim \frac{3}{58\, t+45}$$
Using one more term in the expansion, using $w=W_{-1}\left(-\frac{199}{200 e}\right) \sim -\frac{725}{657}$,
$$a=-\frac{w+1}{(2t+1)}-\frac{w (w+1)}{2 (2t+1)^2}+\frac{w \left(-4   w^2+w+5\right)}{24(2t+1)^3}+\cdots$$
Comment: Interesting! I also obtained very accurate approximation by taking 2 term Taylor expansion of the left tail in terms of $a$ and solving for $t$, $$a\approx \sqrt{\frac{0.005}{2 t^2+3 t+1}}$$ . However, this approach to solve for $b$ gave me something inaccurate
Comment: Some CAS assisted manipulation [here](https://mathematica.stackexchange.com/a/286794/217)  gives the following explicit solution for $$b=\frac{1}{2} \left(\frac{W_{-1}\left(\frac{(1-t)^{1/t} \epsilon  \log (1-t)}{t}\right)}{\log (1-t)}-\frac{1}{t}-1\right)$$ where $\epsilon=0.005$
Answer: The equations to solve $a$ and $b$ can be derived. For example
$$f(t)=\int_0^1 x(1-x)^{2t} \mathrm{d}x
=\frac1{2(t+1)(2t+1)}$$
$$f_a(t)=\int_0^a x(1-x)^{2t} \mathrm{d}x
=\frac{1-(1-a)^{2t+1}}{2t+1}- \frac{1-(1-a)^{2t+2}}{2t+2}$$
Then, set
$$\frac{f_a(t)}{f(t)}=0.005$$
and solve for $a$ in terms of $t$.
Comment: Solving it seems tricky (in terms of Lambert W perhaps?) The interesting part is why the solution is proportional to 1/t?
Answer: I jumped over from the question on the mathematica stackexchange
Starting with
$f_a(a) = (1-a)^{2t+1}(a(2t+1)+1)-\frac{199}{200}$
observe (for some constant $k$)
$f_a(\frac{k}{t}) = -\frac{199}{200} + (1-\frac{k}{t})^{2t+1} (1 + \frac{k(1+2t)}{t})$
In the limit $t->\infty$,
$L(k) =\mathrm{lim}_{t->\infty}f_a(\frac{k}{t}) = -\frac{199}{200}+e^{-2k} (1+2k)$
Finding the root of $L(k)$ produces two constant real solutions for large $t$ (I used Mathematica to find the roots):
$L(k)=0 $
$k_1->\frac{1}{2}\left(-1-W_0(-\frac{199}{200e})\right),\\ k_2->\frac{1}{2}\left(-1-W_{-1}(-\frac{199}{200e})\right)$
Where $W_k$ is the k-th branch of the Lambert $W$ function.
The solutions can also be approximated as
$k_1 -> -0.048406,\\ k_2 -> 0.0517473$
since the domain of a is $0<a<1$ and we constructed our solution to look like $a=k/t$, we know $0<k<t$ for $t>0$, so we select only the positive solution $k_2->\frac{1}{2}\left(-1-W_{-1}(-\frac{199}{200e})\right) \sim 0.0517473 $
so for large $t$
$f_a(a) = (1-a)^{2t+1}(a(2t+1)+1)-\frac{199}{200}=0$
has a solution $a = \frac{k_2}{t}$
Comment: Thanks for the explanation. BTW, using notation of this question, your answer gives the value of $b$. $a$ is actually easier -- doing 2 term Taylor series expansion gave almost perfect fit with this [formula](https://i.stack.imgur.com/Thx6B.png)
Comment: Ah yes I see I think I should've used 1/200 instead of 199/200. And yes that is a much simpler solution


Is the following subspace of $l^2$ complete?

Question: The problem is the following:
Consider the set $$G_2=\{(x_n)\in l_2: \sum_{n=1}^{\infty}x_n=0\}\subset l_2 $$
Is $(G_2,d_2)$ a complete metric space?
$l_2=\{(x_n): \left(\sum_{n=1}^{\infty}|x_n|^2\right)^{1/2}<\infty\}$
$d_2((x_n),(y_n))=\left(\sum_{n=1}^{\infty}|x_n-y_n|^2\right)^{1/2}$
My approach-guess:
In order to prove that this subset of $l_2$ is a complete metric space one needs to find its closure (then $G_2$ is dense in $l^2$), something that did not work so well for me. My guess is that this set is not complete subspace of $l^2$ but I have no idea how to show this. I tried to find a counter-example but I failed. Any help from you would be appreciated!
Comment: If $\sum_{n = 1}^\infty x_n$ doesn't exist, do you consider $x_n$ to be in $G_2$?
Comment: No it will not belong to $G^2$
Comment: @Jack D'Aurizio I think it works because we take a sequence which belongs to $G^2$ and it has it's $\ell^2$ norm tending to infinity when $N\to \infty $. So our subspace is not complete. Right?
Answer: To work out the closure of $G_2$, we could use the fact that $\bar{G_2} = (G_2^\perp)^{\perp}$.
But $G_2^\perp = \{ 0 \}$. [For instance, if $y_n \in G_2^{\perp}$, then the fact that $y_n$ is perpendicular to $(1,-1,0,0, \dots)$, $(0,1, -1,0, \dots)$, $(0,0, 1,-1, \dots), \dots$ means that $y_1 = y_2 = y_3 = \dots$, and the only way that such a $y_n$ can be $l^2$ normalisable is if $y_1 = y_2 = y_3 = \dots = 0$.]
Hence $\bar{G_2} = \{ 0 \}^{\perp} = l^2 \neq G_2$, so $G_2$ is not closed, and hence, not complete.
Comment: Thanks for your answer , but I am new to functional analysis ( this is our 9th excercise for this semester ) and I sadly don't understand fully your answer . Thanks though for your interest, I will upvote and if there is not an easier answer to my question I will accept it. Thanks for your effort :)
Comment: Oh, sorry about that. I think you could have understood it if I explained it better. If $A$ is a subset of a Hilbert space $H$, then $A^\perp$ simply means the set of all elements of $H$ that are perpendicular to every element in $A$. It's a standard fact that the closure of the linear span of $A$ is equal to $(A^\perp)^\perp$. I'm sure it will be in your course.
Comment: We are currently seeing more topological things like completeness conpactness and other stuff like these. So I guess my professor wants a solution involving only these stuff he showed to us. I know a bit of what I am about to see in this course but I like to take things step by step. I think he seeks for a counter example . Thanks again :D
Answer: Let $S^{(N)}$ be the sequence such that $x_0=-1$ and $x_n=\frac{1}{N}$ for any $N+1\leq n\leq 2N$, zero otherwise.
This sequence belongs to $G_2$ and $\{S^{(N)}\}_{N\geq 1}$ is a Cauchy sequence in $\ell^2$, but $\lim_{N\to \infty}S^{(N)}$ is not a zero-sum sequence. This disproves completeness.
Comment: This works properly! Thanks for that , I appreciate it :)
Comment: @KennyWong: it looks to me that this setup works, indeed. We have: $$\left\|S^{(N)}-S^{(M)}\right\|_2 \leq \sqrt{\frac{1}{N}+\frac{1}{M}} \leq \sqrt{\frac{2}{\min(N,M)}}$$ proving that $\{S^{(N)}\}_{N\geq 1}$ is a Cauchy sequence in $\ell^2$.
Comment: You nailed it :P
Comment: Yes, I'm convinced! It's a lovely example, like I said.


Unaddressed Reciepient NDR

Question: I have an issue where a user is sending to a distribution list and that user is receiving an NDR back for an individual who is not a member of the distribution list.  Has anyone else experienced this issue?
Answer: This can happen if one of the members of the distribution list has a delegate set up on their mailbox that is disabled, especially if it was a meeting that was sent to the distribution list.
Comment: Is there an easy way to determine who that might be via powershell?

Unaddressed Reciepient NDR


Number counting functions related to simple groups and asymptotic law of distribution

Question: We say that an positive integer $n$ is a

simple number if there exist a non abelian simple group of order $n$. Denote by $\mathfrak{s}$ this set.
prime-power number if it is of the form $n=p^a$, with $p$ prime. Denote by $\mathfrak{pp}$ this set.
Sylow congruent number if it is a non prime-power number for which the congruence conditions of Sylow's theorem do not force at least one Sylow subgroup to be normal. In other words we can have $n_p\neq 1$ for all primes $p$ dividing $n$. Denote by $\mathfrak{sc}$ this set.

Also denote by $\mathfrak{p}$ the set of prime numbers.
Even though we know of the finite simple groups (I don't but some do), it seems unrealistic to expect an clean characterization of $\mathfrak{s}$.
For a set of positive integers $\mathfrak{t}$ we define $\pi_{\mathfrak{t}}$ the counting function of that set, i.e. $\pi_{\mathfrak{t}}(x)$ gives the number of elements in $\mathfrak{t}$  less than or equal to $x$, for any real number $x$.
It is well-known that $\pi_{\mathfrak{p}}(x)\sim\frac{x}{\ln x}$ (Prime number theorem).

Do we know the asymptotic laws of distribution for the other sets
  defined above, i.e. asymptotic behaviors of $\pi_{\mathfrak{pp}}(x)$,
  $\pi_{\mathfrak{s}}(x)$ and $\pi_{\mathfrak{sc}}(x)$, or $\pi_{\mathbb{N}\setminus \mathfrak{pp}}(x)$, $\pi_{\mathbb{N}\setminus \mathfrak{s}}(x)$ and $\pi_{\mathbb{N}\setminus \mathfrak{sc}}(x)$?

I suspect that we have $\pi_{\mathbb{N}\setminus \mathfrak{sc}}(x)\sim x$, or $\pi_{\mathbb{N}\setminus \mathfrak{sc}}(x)\sim  k x$ for some $0<k<1$ (based on some computation). At least if we restrict to odd numbers.
Comment: I have not thought much about it, but I strongly suspect that the simple numbers are dominated by the orders $p(p^2-1)/2$ of the groups ${\rm PSL}(2,p)$ for odd primes $p$.
Comment: @Nathan: is 12 in SC?
Comment: @Jack: Yes 12 is in SC based only on the congruence criterion of Sylow Theorem, so are 24, 30, 36, 48, 56,...
Comment: @Derek: you are right, very strongly dominated by these numbers. There are 493 non abelian simple groups of order $<10^{10}$, of which 428 are of the type PSL($2,p$) for odd primes $p$. How does one prove it though?
Comment: @Nathan: I show how to prove a similar domination for pp.  s is the same idea, just the sum is over more indices.  All but finitely many simple groups are in families of the form X(r,p,k) and their orders are well approximated by a prime power (usually some large power of p^k), and so the only ones that don't wash out are the ones where r=k=1.
Answer: Here is a simpler problem that should get you going: Instead of counting prime powers, let's just count prime squareds.
$$\pi_{\mathfrak{p}^2}(x) = \#\{ p^2 : p^2 < x, p \in \mathfrak{p} \} = \#\{ p^2 : p < \sqrt{x}, p \in \mathfrak{p} \} = \pi_{\mathfrak{p}}(\sqrt{x})$$
You can estimate this using the good ole PNT:
$$\pi_{\mathfrak{p}^2}(x) \sim \frac{2\sqrt{x}}{\ln(x)}$$

Now several of your sets are basically counting prime powers.  $\mathfrak{pp}$ for instance has a nice expression as:
$$\pi_{\mathfrak{pp}}(x) = \sum_{k=1}^{\log_2(x)} \pi_{\mathfrak{p}^k}(x) = \sum_{k=1}^{\log_2(x)} \pi_{\mathfrak{p}}(x^{(1/k)})$$
The asymptotics are the same:
$$\pi_{\mathfrak{pp}}(x) \sim \frac{x}{\ln(x)}$$
Similarly, I suspect there is no trouble with:
$$\pi_{\mathfrak{s}}(x) \sim \frac{3\sqrt[3]{x}}{\ln(x)}$$

Calculus fun:
$$\lim_{x\to\infty} \frac{ x/\ln(x) } { \sum_{k=1}^{\log_2(x)} kx^{(1/k)}/\ln(x) } = \lim_{x\to\infty} \frac{x}{\sum_{k=1}^{\log_2(x)} kx^{(1/k)}}$$
Clearly the operand of the limit is less than 1 for all $x > 1$, so we squeeze from below:
$$\begin{align} 1
&\geq \lim_{x\to\infty} \frac{x}{\sum_{k=1}^{\log_2(x)} k x^{(1/k)}} \\ \\
&\geq \lim_{x\to\infty} \frac{x}{x + \sqrt{x} \sum_{k=2}^{\log_2(x)} k} \\ \\
&\geq \lim_{x\to\infty} \frac{x}{x+\sqrt{x} (\log_2(x))^2} = 1
\end{align}$$
In the second line, I use that $\sqrt{x} \geq x^{(1/k)}$ for $k \geq 2$, and then in the third line I overestimate an arithmetic series.  In the last line, we divide top and bottom by x and the second term of the denominator goes to 0.
Comment: Thanks a lot Jack, I am skeptical about $\pi_{\mathfrak{s}}(x) \sim \frac{\sqrt{x}}{2\ln(x)}$, because $\pi_{\mathfrak{s}}(10^{10})= 493$, which is about 5 times smaller than the right side of $\sim$. I know it grows slowly, so it may be correct after all...
Comment: @Nathan: Oh sorry, PSL(2,p) has order about p^3 not p^2.  I also had the k in the wrong place.  All fixed now.  The calculus is less fun (arithmetic series instead of harmonic), but no big change.


Imagem para base64

Question: Gostaria de transformar uma imagem para base64, mas não está funcionando corretamente,não há nenhum erro no logcat,alguem poderia me ajudar?
Codigo:
<code> private void galleryIntent() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);//
    startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
}

private void cameraIntent() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(intent, REQUEST_CAMERA);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == SELECT_FILE)
            onSelectFromGalleryResult(data);
        else if (requestCode == REQUEST_CAMERA)
            onCaptureImageResult(data);
    }
}

public void onCaptureImageResult(Intent data) {

    Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] imageBytes = baos.toByteArray();

    String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);

    File destination = new File(Environment.getExternalStorageDirectory(),
            System.currentTimeMillis() + ".jpg");

                                                                                FileOutputStream fo;
                            try {
                                destination.createNewFile();
                                fo = new FileOutputStream(destination);
                                fo.write(baos.toByteArray());
                                fo.close();
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }

                            livview.setImageBitmap(thumbnail);
                        }

@SuppressWarnings("deprecation")
private void onSelectFromGalleryResult(Intent data) {

    Bitmap bm = null;
    if (data != null) {
        try {
            bm = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    livview.setImageBitmap(bm);
}
</code>
Comment: Podes detalhar o que "não está funcionando corretamente" ?
Comment: Gostaria que ele me retornasse o base64 como no systemoutprintln ...mas ele nao retorna nada
Comment: Mesmo depois de colocar             return imageEncoded;
Answer: Consegui carregar a imagem no formato Base64 usando jquery com ajax, segue o código abaixo
<code><script type="text/javascript">
    function uploadFile() {
        var target = document.querySelector("img");
        var file = document.querySelector("input[type=file]").files[0];

        var reader = new FileReader();

        reader.onloadend = function () {

            target.src = reader.result;

            // Upload Ajax
            $.ajax({
                method: "POST",
                url: "VisitanteServlet",
                data: {
                    foto: reader.result
                }
            })
            .done(function(response) {
                //alert("Sucesso: " + response);
            })
            .fail(function(xhr, status, errorThrown) {
                //alert("Error: " + xhr.responseText);
            });
        };

        if (file) {
            reader.readAsDataURL(file);
        } else {
            target.src = "";
        }
    }

</script>
</code>

Imagem para base64


Using svg.js and svg-pan-zoom how can I get current "viewport" center point?

Question: I'm using svg.js and the great svg-pan-zoom plugin ( https://github.com/ariutta/svg-pan-zoom ).
Now I want to have a button that when I click on it it draws a circle on the current center point of the viewport am I seeing (so the position is dynamic depending on the pan/zoom I've done).
I setup a quick example here that draws the circle statically on a specified position.
Please note I have some specific needs: I'm showing a "background" image with a scaling factor like this:
var map = mainWindow.group();
map.addClass('seatMap');
map.image('http://upload.wikimedia.org/wikipedia/commons/b/b3/World-map-2004-cia-factbook-large-1.7m-whitespace-removed.jpg').loaded(function () {
    map.cx(viewboxW / 2);
    map.cy(viewboxH / 2);
}).scale(0.70);

So how can I get the current center point?
Answer: Find the initial centerX and centerY positions(Before zoom) using the code below.
var viewPort = document.getElementsByClassName("viewport")[0];
var bbox = viewPort.getBBox();
var initX = (bbox.x+bbox.width)/2,
    initY = (bbox.y+bbox.height)/2;

You can calculate the center point, after zoom using the code written below.
var pt =  draw.node.createSVGPoint();
pt.x = initX;
pt.y = initY;
pt = pt.matrixTransform(viewPort.getCTM());

pt.x will be the centerX and pt.y will be the centerY positions.
Hope this helps.
Answer: svg-pan-zoom has 2 API methods that may help you:

getSizes
getPan

You may be mostly interested in getSizes as it will return current size of bounding box, real zoom and viewport sizes and positinos.
Answer: I had a similar problem: I wanted to add a rect on the top-left corner of the actual zoomed canvas (the zoomable svg), so I made it this way:
var positionX = -1*svgPanZoom.getPan.x/svgPanZoom.getSizes.realZoom;
var positionY = -1*svgPanZoom.getPan.y/svgPanZoom.getSizes.realZoom;

Hope it helps


Ramanujan log-trigonometric integrals

Question: I discovered the following conjectured identity numerically while studying a family of related integrals.
Let's set
$$
R^{+}:=  \frac{2}{\pi}\int_{0}^{\pi/2}\sqrt[\normalsize{8}]{x^2 + \ln^2\!\cos x}
\sqrt{ \frac{1}{2}+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2}  \sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}\,\mathrm{d}x, \tag1
$$
$$
R^{-}:=  \frac{2}{\pi}\int_{0}^{\pi/2}\frac{1}{\sqrt[\normalsize{8}]{x^2 + \ln^2\!\cos x}}
\sqrt{ \frac{1}{2}+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2} \sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}\,\mathrm{d}x. \tag2
$$
We may numerically observe with at least 500 digits of precision that
$$
\begin{align}
& R^{+}R^{-} \stackrel{?}{=}1 \tag 3 \\\\
& R^{+} \stackrel{?}{=} \sqrt[\normalsize{4}]{\ln 2} \tag4 \\\\
& R^{-} \stackrel{?}{=}\frac{1}{\sqrt[\normalsize{4}]{\ln 2}}. \tag5
\end{align}
$$
How can we prove it?
A version of this has been sent to Eric Weisstein, these integrals are on Mathworld as Ramanujan log-trigonometric integrals.
Comment: The integrals can be rewritten a bit more compactly in the following way:
$$R^+:=\frac{2}{\pi}\int_0^{\pi/2}\text{Re}\left [ (ix-\ln(\cos x))^{1/4} \right ]dx\\R^-:=\frac{2}{\pi}\int_0^{\pi/2}\text{Re}\left [ \left (-ix-\ln(\cos x)\right )^{-1/4} \right ]dx$$
Comment: The identity $$\sqrt{(1/2)+(1/2)\cos\theta}=\sin(\theta/2)$$ suggests making the substitution $$\cos\theta=\sqrt{\log^2\cos x/(x^2+\log^2\cos x)}$$
Comment: My immediate (albeit likely overly optimistic) thought is that their product could be viewed as a double integral, and this "somehow" shown to be equal to unity.
Comment: @semiclassical The double integral seems frightening :)
Comment: Oh, yes. That somehow is a bit like suggesting that it would "somehow" be possible for me to climb Mount Everest---it may be true, but it's still not bloody likely! On a more topical note, it also vaguely reminds me of certain properties of 'functional determinants' in field theory. (But that doesn't help much either!)
Comment: Re Gerry Myerson: And then, perhaps, the half angle formulae in the first terms of Vieta's product for $\pi$.
Comment: @SDiv You are on the right track ;-)
Answer: Here is an approach.
Theorem.
Let $s$ be a real number such that $-1<s<1$. Then

\begin{equation}{\Large\int_{0}^{\!\Large \frac{\pi}{2}}} \frac{\cos \left(\! s \arctan \left(-\frac{x}{\ln \cos x}\right)\right)}{(x^2+\ln^2\! \cos x)^{\Large\frac{s}{2}}}\, \mathrm{d}x = \frac{\pi}{2}\frac{1}{\ln^{\Large s}\!2} \tag1\end{equation}

Proof. First assume  that $0<s<1.$ Then we may write
$$
\begin{align}
\int_{0}^{\!\Large \frac{\pi}{2}} \frac{\cos \left(\! s \arctan \left(-\frac{x}{\ln \cos x}\right)\right)}{(x^2+\ln^2\! \cos x)^{s/2}} \mathrm{d}x
& = \frac{1}{\Gamma(s)}\int_{0}^{\!\Large \frac{\pi}{2}}\!\!\int_{0}^{+\infty} u^{s-1}  \cos (u x) \:e^{u \ln \cos x}\:\mathrm{d}u \:\mathrm{d}x \tag2\\\\
& = \frac{1}{\Gamma(s)}\int_{0}^{+\infty}u^{s-1}\!\!\int_{0}^{\!\Large  \frac{\pi}{2}}  \cos^u\! x \cos (u x)\:\mathrm{d}x \:\mathrm{d}u \tag3\\\\
& = \frac{1}{\Gamma(s)}\int_{0}^{+\infty}u^{s-1} \frac{\pi}{2^{u+1}}\:\mathrm{d}u \tag4\\\\
& = \frac{\pi}{2} \frac{1}{\Gamma(s)}\int_{0}^{+\infty}u^{s-1} e^{-u\ln 2}\:\mathrm{d}u \tag5\\\\
& = \frac{\pi}{2}\frac{1}{\Gamma(s)}\frac{\Gamma(s)}{\ln^{s}\!2} \tag6\\\\
& = \frac{\pi}{2}\frac{1}{\ln^{s}\!2} \tag7
\end{align}
$$
where we have used Fubini's theorem and the classic results (here and there)
$$
\begin{align}
& \int_{0}^{+\infty} u^{s-1}  \cos (a u) \:e^{-b u}\:\mathrm{d}u = \Gamma (s)\frac{\cos \left(\! s \arctan \left(\frac{a}{b}\right)\right)}{(a^2+b^2)^{s/2}}, \, \left(\Re(s)>0, b>0, a>0 \right) \tag8 \\
& \int_{0}^{\!\Large  \frac{\pi}{2}}  \cos^u\! x \cos (u x)\:\mathrm{d}x = \frac{\pi}{2^{u+1}}, \quad u>-1. \tag9
\end{align}
$$
We may extend identity $(7)$ by analytic continuation to obtain $(1)$.
Example 1. We have

$$
\int_{0}^{\pi/2}\displaystyle
\sqrt{\sqrt{x^2 + \ln^2\!\cos x}-\ln\! \cos x}\,\,\mathrm{d}x = \frac{\pi}{2}\sqrt{2\ln 2} \tag{10}
$$

and

$$
\int_{0}^{\pi/2}\displaystyle
\frac{1}{\sqrt{x^2 + \ln^2\!\cos x}} \sqrt{\sqrt{x^2 + \ln^2\!\cos x}-\ln\! \cos x}\,\,\mathrm{d}x = \frac{\pi}{\sqrt{2\ln 2}} \tag{11}
$$

Proof. Let $0<x<\frac{\pi}{2}$ and set $t:=\arctan \left(-\frac{x}{\ln \cos x}\right)$.  Observe that $0 < t < \frac{\pi}{2}$ and
$$
\cos t=\cos \left(\!\arctan \left(-\frac{x}{\ln \cos x}\right)\right)= -\frac{\ln \cos x}{\sqrt{x^2 + \ln^2\!\cos x}},
$$
$$
\cos \left(\frac{t}{2}\right) = \sqrt{
\frac{1}{2}+ \frac{1}{2} \cos t}
$$
 then put successively $\displaystyle s=-\frac{1}{2}$, $\displaystyle s=\frac{1}{2}$ in $(1)$ to obtain $(10)$ and $(11)$.
Example 2.

$$
\frac{2}{\pi}\int_{0}^{\pi/2}\sqrt[\normalsize{8}]{x^2 + \ln^2\!\cos x}
\sqrt{ \frac{1}{2}+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2}  \sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}\,\mathrm{d}x = \sqrt[\normalsize{4}]{\ln 2}
\tag{12} $$

and

$$
\frac{2}{\pi}\int_{0}^{\pi/2}\frac{1}{\sqrt[\normalsize{8}]{x^2 + \ln^2\!\cos x}}
\sqrt{ \frac{1}{2}+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2} \sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}\,\mathrm{d}x=\frac{1}{\sqrt[\normalsize{4}]{\ln 2}}
\tag{13} $$

Proof. Let $0<x<\frac{\pi}{2}$ and set $t:=\arctan \left(-\frac{x}{\ln \cos x}\right)$.  Observe that $0 < t < \frac{\pi}{2}$ and
$$
\cos t=\cos \left(\!\arctan \left(-\frac{x}{\ln \cos x}\right)\right)=\sqrt{ \frac{\ln^{2}\!\cos x}{x^2 + \ln^2\! \cos x}},
$$
$$
\cos \left(\frac{t}{4}\right) = \sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2} \cos t}},
$$  then put successively $\displaystyle s=-\frac{1}{4}$, $\displaystyle s=\frac{1}{4}$ in $(1)$ to obtain $(12)$ and $(13)$.
Example n.
Set

$$
R_n^{+}:=\frac{2}{\pi}\int_{0}^{\pi/2}\sqrt[\Large {2^n}]{x^2 + \ln^2\!\cos x}
\sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}+\cdots+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2}\sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}}\,\mathrm{d}x
$$

and

$$
R_n^{-}:=\frac{2}{\pi}\int_{0}^{\pi/2}\frac{1}{\sqrt[\Large {2^n}]{x^2 + \ln^2\!\cos x}}
\sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}+\cdots+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2}\sqrt{ \frac{\ln^{2}\!\cos x}{
x^2 + \ln^2\! \cos x}}}}}\,\mathrm{d}x.
$$

Then

$$
R_n^{+}= \sqrt[\Large {2^n}]{\ln 2}
\tag{14}
$$

and

$$
R_n^{-}= \frac{1}{\sqrt[\Large {2^n}]{\ln 2}}
\tag{15}.
$$

Proof. Let $0<x<\frac{\pi}{2}$ and set $t:=\arctan \left(-\frac{x}{\ln \cos x}\right)$.  Observe that $0 < t < \frac{\pi}{2}$ and
$$
\cos t=\sqrt{ \frac{\ln^{2}\!\cos x}{x^2 + \ln^2\! \cos x}},
$$
$$
\cos \left(\frac{t}{2^n}\right) = \sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}+\cdots+\frac{1}{2}\sqrt{
\frac{1}{2}+ \frac{1}{2} \cos t}}}},
$$  then put successively $\displaystyle s=-\frac{1}{2^n}$, $\displaystyle s=\frac{1}{2^n}$, $n\geq 1,$ in $(1)$ to obtain $(14)$ and $(15)$.
Comment: Much more professional than my answer! I knew you were holding out on us.
Comment: OK fine, I am able to prove equation (8) & (9) by myself
Comment: @Anastasiya-Romanova   Because the positive square root of $\log^{2} (\cos x)$ for $0 \le x \le \frac{\pi}{2}$ is $-\log \cos x$. Perhaps $s$ needs to be further restricted.
Comment: Wow, this is very impressive, but the only thing I haven't understood yet is how did you get the equality $(2)$, may I have miss something in your reasonning or it is obvious? :)
Comment: Very brilliant approach & great answer, but how to prove equation (8) & (9)? The cited links don't contain the proofs. +1 anyway
Comment: @SDiv I really congratulate you for having found a route! Maybe it would be interesting to have your real name to cite your answer in an eventual paper on the subject. Thanks.
Comment: Mr. Oloa, I wanna ask something for the Theorem (1). When I plug in $s=1$, the numeric value of the integral is [$0.695384$](http://www.wolframalpha.com/input/?i=Integrate%5B++Cos%5BArcTan%5B-%28x%2FLog%5BCos%5Bx%5D%5D%29%5D%5D%2FSqrt%5Bx%5E2+%2B+Log%5BCos%5Bx%5D%5D%5E2%5D%2C+%7Bx%2C+0%2C++++Pi%2F2%7D%5D) but [$\dfrac{\pi}{2\ln2}\approx2.26618$](http://www.wolframalpha.com/input/?i=%28pi%2F2%29%2Fln%282%29). Why $RHS\neq LHS$?
Comment: For $s=1$, $(1)$ evaluates to $\frac{\pi}{2 \ln 2} - \frac{\pi}{2}$ http://math.stackexchange.com/questions/325651/definite-integral-int-0-pi-2-frac-log-cos-xx2-log2-cos-xdx-f My guess is that the problem arises when you switch the order of integration.
Comment: @RandomVariable The OP that you cite, is that wrong since it's evaluated as $\dfrac{\pi}{2}\left(1-\dfrac{1}{\log 2}\right)$?
Comment: @Anastasiya-Romanova $(1)$ evaluated at $s=1$ is the negative of that integral.
Comment: @RandomVariable How come it's the negative of the other integral? Plug in $s=1$ to (1), the integral is $$\int_0^{\pi/2} \frac{\log(\cos x)}{x^2+\log^2(\cos x)}dx$$Anyway, plug in $s=2$ to (1), according to [W|A](http://www.wolframalpha.com/input/?i=Integrate%5B++Cos%5B2ArcTan%5B-%28x%2FLog%5BCos%5Bx%5D%5D%29%5D%5D%2F%5Bx%5E2+%2B+Log%5BCos%5Bx%5D%5D%5E2%5D%2C+%7Bx%2C+0%2C++++Pi%2F2%7D%5D) the integral doesn't converge
Comment: @RandomVariable Hhmmm, That makes sense
Comment: @Anastasiya-Romanova Identity $(1)$ is true for $-1<s<1,$ further extension need some care. I've fixed it. Thanks!
Comment: @OlivierOloa Hhmmm, I deserve a credit for my comment because it's helpful, lol. (kidding) Anyway, could you please extend your theorem for $s\ge1$? Especially for $s=1$, I'm curious. Thanks... ≥Ö‿Ö≤
Comment: this is sick (+1)!
Comment: I'm confused as to how you knew to start from the integral$${\Large\int_{0}^{\!\Large \frac{\pi}{2}}} \frac{\cos \left(\! s \arctan \left(-\frac{x}{\ln \cos x}\right)\right)}{(x^2+\ln^2\! \cos x)^{\Large\frac{s}{2}}}\, \mathrm{d}x = \frac{\pi}{2}\frac{1}{\ln^{\Large s}\!2}$$What lend you to start off with it and how did you know it would have a nice closed form?
Answer: Oloa was right, I was on the right track last night (it makes me wonder if he has already solved it and just didn't tell us?). The final trick is to realize $(ix-\ln(\cos x))^{1/4}=\ln(1+i\tan(x))^{1/4}$ and then make the substitution $u=1+i\tan x$. This gives $R^+=\frac{2}{\pi}\text{Re}\lbrace\frac{i}{2}\Gamma(5/4) \text{PolyLog}(5/4, 2)\rbrace=(\ln 2)^{1/4}$. Details to follow in an edit in the next few minutes.
Edit: details follow
So, this may not be the best way but at least it's a way:
To get to the compact form I posted in the above comment, let $\theta(x)$ be such that $$\cos(\theta(x))=\frac{-\ln(\cos x)}{\sqrt{x^2+\ln^2(\cos x)}}.$$ Considering the right triangle with legs $x$ and $-\ln(\cos x)$ we notice that the hypotenuse is given by $h(x)=\sqrt{x^2+\ln^2(\cos x)}$ and further that $\sin(\theta(x))=\frac{x}{h(x)}$. This gives, using the correct identity $\sqrt{1/2+1/2\cos x}=\cos(x/2)$:
$$R^+:=\frac{2}{\pi}\int_0^{\pi/2}\left(\frac{x}{\sin(\theta[x])}\right )^{1/4}\cos\left (\frac{\theta[x]}{4}\right )dx\\R^-:=\frac{2}{\pi}\int_0^{\pi/2}\left(\frac{x}{\sin(\theta[x])}\right )^{-1/4}\cos\left (\frac{\theta[x]}{4}\right )dx. $$
The trick is now to turn that $\theta/4$ into some kind of 4th root. We use the exponential definition of cosine:
$\cos(\theta/4)=\frac{1}{2}\left ( e^{i\theta/4}+e^{-i\theta/4} \right )=\frac{1}{2}\left ( \left [\cos\theta+i\sin\theta \right ]^{1/4}+\left [\cos\theta-i\sin\theta \right ]^{1/4} \right )$. Then we have $$\left(\frac{x}{\sin(\theta[x])}\right )^{1/4}\cos\left (\frac{\theta[x]}{4}\right )=\frac{1}{2}\left ( [x\cot\theta+ix]^{1/4}+[x\cot\theta-ix]^{1/4} \right ).$$ Considering the triangle again this gives $$\left(\frac{x}{\sin(\theta[x])}\right )^{1/4}\cos\left (\frac{\theta[x]}{4}\right )=\frac{1}{2}\left ( [-\ln(\cos x)+ix]^{1/4}+[-\ln(\cos x)-ix]^{1/4} \right )\\=\text{Re}\left \lbrace [-\ln(\cos x)+ix]^{1/4} \right \rbrace. $$ Similar methods show $$\left(\frac{x}{\sin(\theta[x])}\right )^{-1/4}\cos\left (\frac{\theta[x]}{4}\right )=\text{Re}\left \lbrace [-\ln(\cos x)-ix]^{-1/4} \right \rbrace.$$ Now we use the addition property of logarithms and the exponental form of cosine again:$$-\ln(\cos x)+ix=-\ln(e^{ix}/2+e^{-ix}/2)+\ln(e^{ix})=\ln\left ( \frac{2e^{ix}}{e^{ix}+e^{-ix}} \right ) \\=\ln(1+i\tan x).$$ Similarly, $-\ln(\cos x)-ix=\ln(1-i\tan x).$ Okay, putting this together gives, using the fact that the integral over a real part is the real part of an integral: $$R^+=\frac{2}{\pi}\text{Re}\left \lbrace \int_0^{\pi/2}\ln(1+i\tan x)^{1/4}dx \right  \rbrace \\ R^-=\frac{2}{\pi}\text{Re}\left \lbrace \int_0^{\pi/2}\ln(1-i\tan x)^{-1/4}dx \right  \rbrace.$$ It seems that Mathematica still couldn't solve this, but with a simple substitution it works. For $R^+$ let $u=1+i\tan x$. Then $$ R^+=\frac{2}{\pi}\text{Re}\left \lbrace i\int_1^{1+i\infty}\frac{\ln(u)^{1/4}}{u^2-2u}du \right  \rbrace\\=\frac{2}{\pi}\text{Re}\lbrace\frac{i}{2}\Gamma(5/4) \text{PolyLog}(5/4, 2)\rbrace\\=(\ln 2)^{1/4}.$$ I assume someone skilled in contour integration can do whatever Mathematica did to get this answer. For $R^-$ let $u=1-i\tan x$. Then $$ R^-=\frac{2}{\pi}\text{Re}\left \lbrace i\int_1^{1-i\infty}\frac{\ln(u)^{-1/4}}{u^2-2u}du \right  \rbrace\\=\frac{2}{\pi}\text{Re}\lbrace\frac{i}{2}\Gamma(3/4) \text{PolyLog}(3/4, 2)\rbrace\\=(\ln 2)^{-1/4}.$$ I had to fudge a minus sign on this one, probably something with direction of contour integration or something. Anyway, conjecture confirmed. I assume similar methods can be used to confirm the nth order Ramanujan Log-Trigonometric Integral as mentioned by Oloa. Specifically, it seems we have $$R_n^+=\frac{2}{\pi}\text{Re}\left \lbrace \int_0^{\pi/2}\ln(1+i\tan x)^{1/(2^n)}dx \right  \rbrace \\ R_n^-=\frac{2}{\pi}\text{Re}\left \lbrace \int_0^{\pi/2}\ln(1-i\tan x)^{-1/(2^n)}dx \right  \rbrace.$$
Edit:
It was silly for me to choose different representations for the real part. Better to chose the same one in which case we have:
$$R_n^\pm=\frac{2}{\pi}\text{Re}\left \lbrace \int_0^{\pi/2}\ln(1+i\tan x)^{\pm 1/(2^n)}dx \right  \rbrace.$$
Comment: Congratulations! They are some details to clarify, but you did it! "Mille bravos !" Thank you for your time!

Ramanujan log-trigonometric integrals


Como criar regex que aceite somente caracteres sem acentos

Question: No meu formulário html, tenho o campo "nome".
Nesse campo, quero permitir que o campo aceite somente caracteres sem acentos.
Como fazer essa validação utilizando Regex?
Não quero uma função, quero colocar um tipo de atributo no campo que bloqueie acentos.
Answer: Pode utilizar o atributo pattern do input, utilizando a regex [A-Za-z ]*...

<form action="...">

  <input name="username" id="username" type="text" pattern="[A-Za-z ]*" title="Somente letras sem acento">

  <input type="submit">
</form>
Answer: Criei um regex da seguinte forma:
/[a-zA-Z ]/


PHP Javascript - Erro no IF

Question: Estou com o código abaixo, porém ele não está obedecendo a comparação dos if's, sempre coloca o último valor mesmo sem passar por ele, segue código:
<?php $minhavar = 100; ?>

<!DOCTYPE html>

Teste

Trocar valor da variavel php

<form name="form1">

<input type ="text" id="varhtml" value = 1 >

<button onclick="myFunction()">Click me</button>

</form>

O problema continua (preciso trocar o valor da variavel PHP $minhavar) ver código abaixo:
<?php
$minhavar = 100;
?>
<!DOCTYPE html>

teste

trocar valor da variavel php

<form name="form1">
<input type ="number" id="varhtml" name = "varhtml" value = 1 >
<button onclick="myFunction()">Click me</button>
<button onclick="vervalor()">Ver Valor variavel </button>
</form>

Answer: Basicamente o problema é que não é possível determinar o valor da variável PHP $minhavar com o if do JavaScript.

Quando fui ver no view-souce da pagina ele ja executa todos os <?php e
  sempre prevalece o ultimo.

Isso ocorre porque o PHP (que é server side) não interpreta (não executa os comandos) do que está fora das tags <?php  ?>, ou <?  ?> (e o que está dentro de comentários).
Para o PHP, tudo que está fora destas tags (ou dentro de comentários) simplesmente "não existe" (como comandos). Todo este if/else do JavaScript é apenas um "texto qualquer" que será enviado para o navegador sem sofrer alteração pelo interpretador do PHP.
Este é o código que o PHP enviou para  o navegador renderizar:
function myFunction() {

            var item = form1.varhtml.value;

            if (item == 1) {
                alert("1200");
            }
            else if (item == 2){
                alert("2200") ;
            }
            else if (item == 3){
                alert("3200") ;
            }

        }

Exatamente o que você mandou ele fazer quando disse que $minhavar valia x ($minhavar = 1.200 p.ex) e deu um echo (mandou escrever) logo em seguida.
Quem vai interpretar o que está dentro das tags  é o navegador (client side). Aqui tem uma boa pergunta com algumas ótimas respostas sobre a diferença entre server side e client side: Qual a diferença entre código client-side e server-side em desenvolvimento web?
Resumindo, não é possível mudar o valor de uma variável PHP em decorrência de uma condição de um código JavaScript, porque o primeiro roda no servidor (e não entende as tag

<?php echo $minhavar; ?> // saída é sempre R$ 3.200

Comment: Bom Dia Gustavo, continua com o mesmo problema. o que preciso é trocar o valor de uma variavel PHP $minhavar dependendo do valor escolhido. Quando fui ver no view-souce da pagina ele ja executa todos os <?php e sempre prevalece o ultimo. vou deixar o novo codigo abaixo para voce ver com um botao para mostra o valor atual da variavel PHP $minhavar.
Comment: Vi que os IFs ele ate executa corretamente o problema esta nas instrucoes <?php que sao executadas logo quando chamo a pagina.
Comment: @mariofel Editei a resposta tentando esclarecer as dúvidas do seu comentário. Da forma como você está querendo fazer, acredito que não seja possível.
Comment: Gustavo, valeu. Vou criar um outro .PHP e enviar via POST e la monto a minha logica. Obrigado.
Comment: @mariofel Não entendi muito bem qual o resultado final que vc quer, o comportamento que espera da aplicação. Se for apresentar os dados na mesma página dá pra fazer só com o JS. Se precisar gravar no bd dá pra fazer com `ajax`, tudo sem precisar de `post`, sem dar reload na página ou abrir outra... o que não dá é pra mudar o valor da variável do PHP pelo if do JS... Mas blz, se resolveu então tranquilo. abs

PHP Javascript - Erro no IF


Is there a python special character for a blank value?

Question: I don't know how to ask this so I'm going to explain what I'm doing instead. I'm trying to search a list of lists with only 2 values. The first value I don't care about the second how ever I need to check and if it exsists I need the first value. Example
list = [[1,'text1'],[1,'text2'],[3,'text3'],[2,'text4']]

so basically I need to know if there is a character like % or ! that when used in find basically means any value. Link find(!,'text2') would get me the value of 1. (i know that wouldn't work like that). Ik I have the option of searching just the second value in lists but that's unecessary code if there is a special character as such.
Comment: Special cases aren't special enough to break the rules.
Answer: There is no specific character or value for that, but you can either create your own sentinel object or you can use None for this. Just make sure to use is to detect it within your code.
# fmod.py
Any = object()
def find(first=Any, second=Any):
  if first is Any:
   ...

...
import fmod

fmod.find(None, 'text2')
fmod.find(fmod.Any, 'text2')

Comment: I give. What is `import fmod` do?
Comment: The first code block he's calling `fmod.py` (in the comments), so it would import that.  Rolling-your-own object to compare against (`fmod.Any`) seems *very* strange.
Comment: @NickT: Unless `None` is a valid value to search for.
Answer: Try None value.
You can read more information about it here: Python 3 Constrants
Answer: When you say "the second how ever I need to check and if it exists I need the first value", I'm thinking you need to check if the second value is a) there (if the list has two elements) and b) of nonzero length (assuming they'll always be strings). This leads me to:
list_to_search = [[1,'text1'],[1,'text2'],[3,'text3'],[2,'text4'], [3], [4, '']]
firsts_with_seconds = [item[0] for item in list_to_search
                               if len(item) > 0 and len(item[1]) > 0]

Answer: You can do this with a list comprehension:
def findit(word, lst):
    return [el[0] for el in lst if el[1] == word][0]

Comment: Well I was trying to avoid making my own search but apparently that's my option.


Como obter o resultado da query executada no Eloquent?

Question: Como faço para obter o resultado da query que será executada no banco de dados?
Exemplo:
foreach ($prestadores as $prestador){
  $achou = \DB::table('modulo_pr_espelho')
           ->where('prestador_id','=', $prestador->id)
           ->whereMonth('data_emissao',$mes)->get();
     if (!isset($achou)) {
           print "Prestador : " . $prestador->razao_social;
     }
}

Preciso saber como o Eloquent está montando esta query:
select modulo_pr_espelho.* where prestador_id = 1 where month(data_emissao) = 11

Qual o método que recupero o select puro que foi montado pelo Eloquent?
Answer: Pode usar o metodo toSql() sobre o builder:
$achou = \DB::table('modulo_pr_espelho')
            ->where('prestador_id','=', $prestador->id)
            ->whereMonth('data_emissao',$mes)->toSql();

Desta maneira não tem acesso aos parametros da query (bindings), para conseguir o array com os parametros pode:
$achou = \DB::table('modulo_pr_espelho')
            ->where('prestador_id','=', $prestador->id)
            ->whereMonth('data_emissao',$mes)->getBindings();

Comment: funcionou obrigado!
Comment: De nada @MarceloGomes


No emulator image found while creating a mobile chrome app for android

Question: I'm trying to develop a mobile chrome app.
Here are the steps I followed:

Install JDK 7
Install node
Install cca
Install ant
Install android-sdk
Create a basic "hello-world" desktop chrome app
cd to hello-world and run cca create mobile-hello-world
cd to mobile-hello-world and run cca run android

Here is the error message I get:
ERROR : No emulator images (avds) found, if you would like to create an
 avd follow the instructions provided here:
 http://developer.android.com/tools/devices/index.html
 Or run 'android create avd --name <name> --target <targetID>'
 in on the command line.

Isn't cca supposed to take care of creating an emulator image for me?
I don't see any instructions in mobile chrome app documentation for this. What should I do?
Comment: Have you tried to follow the instructions?
Comment: @Xan, yes. The steps I tried are the same as in the instructions.
Comment: And by that I mean instructions in the error message
Comment: @Xan, yes, I did. It works, but the chrome app that gets launched in the emulator just terminates unexpectedly with an "unfortunately calculator has stopped" kind of message. I tried with several genuine supposed-to-work apps officially written by Google. Also I think there was no need to start the emulator image myself. cca was supposed to do it I think.
Comment: Sorry I missed this earlier.  Given that you have created the image now, I'm assuming your new error is unrelated to the description of this question.  Have you resolved the issue?  May you describe the problem?
Comment: @mmocny, no I haven't resolved this. That is all that happens. It installs the apk into the emulator and then I see a dialog in the emulator that says: "unfortunately calculator has stopped".
Comment: May you run "adb logcat" and then try to run the application to see if you get some stack dumps?  This is unexpected and is the first time report.  If you don't mind [filing an issue with us](https://github.com/MobileChromeApps/mobile-chrome-apps/issues), then we can try to help resolve it.  Would be best to start from the beginning to make sure your environment and emulator are set up right -- have you tried on a real device?
Comment: [Similar link with more possible solution options][1]

  [1]: http://stackoverflow.com/questions/9712605/emulator-error-this-avds-configuration-is-missing-a-kernel-file
Answer: Using the GUI to create a target image helps for point and clickers like me! Run android avd to create as many images you need.

You'll need to have the SDK installed first, of course; the steps 2 & 3 from the following worked for me:
http://docs.phonegap.com/en/2.8.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android
These instructions are for 2.8, but worked for me using Cordova 3.5
Run android from the commandline to open the SDK manager, and update required components.
Answer: Open Android SDK Manager and be sure that ARM EABI v7a System Image is installed.


How can sort DataSeries based values and index?

Question: I have a dataseries (mean_ratings) like below:
A. Morin                  39203.340909
AMMA                      53476.250000
Acalli                    43798.333333
Adi                       41277.500000
Aequare (Gianduja)        45185.000000
                              ...
Zokoko                    44615.000000
Zotter                    46138.326531
hello cocoa               26162.333333
hexx                      35043.333333
twenty-four blackbirds    36877.666667

I sort this series with this code:
best_ratings = mean_ratings.sort_values(0,ascending=False)

Idilio (Felchlin)                  70040.000000
Dole (Guittard)                    65662.500000
Chocola'te                         64725.000000
Christopher Morel (Felchlin)       63787.500000
Madecasse (Cinagra)                62454.166667
Salgado                            61285.000000
Compania de Chocolate (Salgado)    61285.000000
Chloe Chocolat                     61285.000000
Oialla by Bojessen (Malmo)         61285.000000
Rozsavolgyi                        61285.000000

But I want to sort this, first based on values , and then for equal values based on alphabetic indexes.
How can I do this simultaneously?
Comment: Please provide enough code so others can better understand or reproduce the problem.
Answer: You have to use kind='mergesort' on the second sort. Something like:
df.sort_index().sort_values(0, ascending=False, kind='mergesort')

Comment: Sorry wrong order! I updated my answer. Can you check it please. Please provide a relevant sample.
Comment: I do this but it doesn't work.
Answer: Pass .sort_values() a list of the column names you wish to sort by to sort at multiple levels!
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_values.html
>>> df = pd.DataFrame({'foo':['a', 'a', 'b', 'c'], 'bar':[2,1,4,3]})
>>> df
  foo  bar
0   a    2
1   a    1
2   b    4
3   c    3
>>> df.sort_values(["foo", "bar"])
  foo  bar
1   a    1
0   a    2
2   b    4
3   c    3
>>> df.sort_values(["bar", "foo"])
  foo  bar
1   a    1
0   a    2
3   c    3
2   b    4

Comment: It seems the first column is the index.
Comment: oh, I'd misread a confusing Question - it should just be sorted in two rounds
Comment: Thank you for your attention, but I want to sort simultaneously based on index, not two columns.
Comment: @AmirhosseinZohoorian. Use the `kind` parameter of `sort_index` to use a stable algorithm.
Comment: are the names the index? you could `.reset_index()` 'em to a new column first too


Getting printer IP Address from Server\PrinterName

Question: I have a printer installed on the network, and I am looking for a method of resolving the IP address to the name and vice versa.
So firstly the printer is plugged into a network socket. It has its own name and a static IP Address.
Like this, I can send text to it by opening a connection to the IP Address and firing a stream of data (ZPL) to it.
Secondly - the printer is installed on a print server.
\\PRINT_SERVER\Windows_Printer_Name
Checking in the properties I can find the IP Address of it under 'Ports' and 'Configure Port'. (Instead of a local port like COM1 or LPT1, it uses a TCP/IP 'port' which is an IP Address)
I need an automated way of finding this IP Address from the windows path.
Well, what I ACTUALLY need to do is to work the other way round. From an IP Address, find the server/name - but I can see that being not so easy..
I'm working in .NET, so a method through that would be perfect, but I could possibly live with parsing something from the command line if necessary.
Assuming it is possible at all?
Thanks

Edited for clarity
Answer: a command line argument from way back then used to be nbtstat which "Displays protocol statistics and current TCP/IP connections using NBT (NetBIOS over TCP/IP)" with the -A switch
nbtstat -A 192.168.0.1

assuming your server ipname is 192.168.0.1
getting ip from servername would be to use ping :)
ping servername

Comment: But my printer is installed on the server as \\server\a_name_the_admin_chose - not the device name on the network -  the IP of the printer is not the IP of the print server. If I delete the windows driver it is still a valid network identity
Answer: Late to the party but anyone interested a command line script. This lists printer's queue name and port value. I think real IP address is not that easy to resolve, port value is not always IP address, sometimes has 220.127.116.11_IP suffix or IP_ prefix string.
' c:> cscript -nologo scriptname.vbs

Option Explicit

Dim StdOut: Set StdOut = WScript.StdOut
Dim owshNetwork: Set owshNetwork = CreateObject("WScript.Network")
Dim oPrinters
Dim idx

Set oPrinters = owshNetwork.EnumPrinterConnections

for idx=0 to oPrinters.count/2-1
    StdOut.WriteLine "Name=" & oPrinters.Item(idx*2+1) & ", Port=" & oPrinters.Item(idx*2)
next


Proof relation between diagonalization and eigenvectors

Question: I have to proove that $A \; n \times n$ is diagonalizable iff its eigenvectors form a basis of $\mathbb{C}^n$.
$(\to)$ If $A$ is diagonalizable then $A = SBS^{-1}$. Then
$$A = SBS^{-1} \leftrightarrow AS=SD \leftrightarrow ASe_i=SDe_i = d_i (Se_i)$$
The set $V = \{Se_1, ..., Se_n\}$ is the set of column of $S$. Each column of $S$ is an eigenvector of $A$.
Also, $S$ is invertible. It means $rkS=n$, so the set $V$ form a basis of $\mathbb{C}^n$.
$(\leftarrow)$ ?
My question is: how can I prove the second part of the question?
Comment: Is the matrix entries in C??
Comment: @user8795 yes--
Answer: If we take a basis then the vectors of the basis are linearly independent, so if we take the vectors as column vectors of a matrix $A$ then the matrix is of full rank. We find the corresponding characteristics equation and all roots of the equation are its eigen-values of the matrix. Also all roots belong, as $\Bbb C$ is algebraically closed.
Once you got the eigen-values you can easily get the corresponding eigen-vectors and create the corresponding matrix $P$. $D$ the diagonal matrix consists the eigen-values in its diagonal entry. Thus $$A = P^{-1}DP$$
Hence $A$ is diagonalizable.
Comment: Sorry, just one thing. I've got $P$ which is made by the vector of the basis. I know that $P$ is full rank so it's invertibile. How can I proove that exists $D$ such that $P^{−1}DP=A$?


How to securise custom modules

Question: I'm trying to understand how to securise my custom modules to avoid php insert into custom inputs and SQL injections in my db_query.
For inputs I'm using :
$form['custom'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom),
      '#description' => t('Custom'),
      '#default_value' => '',
)

I tried to insert some PHP in the input and it actually run it whereas in the documentation it saiys that using form API should escape PHP by using check_plain and the safe example given is :
$form['also_safe'] = array(
  '#type' => 'select',
  '#default_value' => 0, // FAPI will pass through check_plain(),
  '#options' => node_get_types('names'),  // FAPI will sanitize the '#options' attribute with check_plain() for select boxes.
);

So what am I doing wrong ?
Concerning my SQL query I can't succeed to use as documented :
$result = db_query('SELECT $ FROM {custom} WHERE uid= :uid", array(':uid' => $value['in_array'])).

When calling a non object value I just get an error, so doing something like that works well but doesn't escape SQL injection :
$to_user_balance = db_query("SELECT * FROM {ubercart_funds_user_funds} WHERE uid=" . $value['in_array']));

I have to precise that I'm actually learning PHP and still didn't get what objects are. Because my aim is result and not capability, if somebody can explain me quickly how to securise my queries and inputs or drive me to a clear documentation.
I already know those documentation page and didn't help :

Handle user input with care
db_query
Comment: I suppose the syntax error in your db_query is an accident in the question? (You open with a single quote and close with a double one.)
Comment: Ha ... Yeah ... It's an accident when I wrote it here.
Comment: _I just get an error_ What error do you get?
Answer: It's a better idea to use db_select or other DB API functions, rather than trying to use db_query directly. You'd want to try something like:
 $to_user_balance = db_select('ubercart_funds_user_funds', 'ucfuf')
   ->fields('ucfuf')
   ->condition("uid", $value['in_array'], '=')
   ->execute()
   ->fetchAssoc();

For more, see https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_select/7.x
And for overall DB API docs, see: Drupal.org DB API docs
Comment: I have read, I don't remember where, that db_query is such more efficient than db_select so I would prefer to use db_query. Also is it going to secure my queries (if I use db_select) because for me the problem will still be the same. Is it possible to select non objects datas ?
Comment: @Aporie db_query is slightly faster, but not noticeable unless you start doing hundreds of queries in one request. If this is for fetching one or two results, db_select is safer and easier to read.
Comment: My apologies guys, it seems that I was just forgetting the ->fetchAssoc; statement at the end of my db_query line. Everything seems to work correctly now. I still have some doubt about the possibility to insert php into the input of the form. I think I'm gonna update ubercart_funds module, because I'm working on it for a while and I hope it will pass drupal security requirements.

How to securise custom modules


db_affected_rows in Drupal 7 for db_query

Question: I just noticed that @Berdir was so nice to remove db_affected_rows from Drupal 7. I'm now wondering what the best practice is now to detect if the query you ran changed anything in the database.
A typical usecase would be to.
db_query(...);
if (!db_affected_rows()) {
  db_query(...);
}

I took a look at the query object returned from db_query, but it didn't seem like much help.
Update:
I see I was a bit unclear as to what circumstances I needed the info.
My current use case, is a quite simple one. I have a table for a node type with a nid column and some data columns. I have a form an upon submitting the form, I want to either insert or update the row in the db.
The problem with db_update/db_insert is that, if I use update first, and insert if update returns 0, I wont catch the condition, where the form was submitted with the value in the db. If I use db_insert first, that will raise en error if there already is a row in the db.
I suppose I in this specific condition could insert a blank value when the node is created and then only use update, but for some cases that might not be possible, if I needed to store info that was keyed to an external database. I would also like to avoid having to depend on database values for my code to function.
My usual strategy for such cases, has been to do a
db_query("INSERT IGNORE INTO ...")
if (!db_affected_rows()) {
  db_query("UPDATE ...");
}

Doing this is both simple and error free no matter what condition the db is in. The best option I can see right now, would be to handle it with SQL and do this:
db_query("INSERT ... ON DUPLICATE KEY UPDATE");

But I was hoping that the db API would be able to handle this.
Answer: That information is directly returned by the execute() method of Delete/UpdateQuery, see for example: UpdateQuery::execute().
<?php
$affected = db_update('some_table')
  ->fields(array(
    'some_field' => $value,
  ))
  ->condition('another_field', $id)
  ->execute();
?>

And InsertQuery::execute() returns the last insert id.
Answer: After digging around, I found that Drupal supplies a ready named tool for my exact use case:
Insert a row in the db, or update the existing if it's already there.
This is called merge queries, which can be done atomically for some db engines.
The syntext is pretty simple:
db_merge('example')
  ->key(array('name' => $name))
  ->fields(array(
    'field1' => $value1,
    'field2' => $value2,
))
->execute();

Comment: Ah yes, that is the correct answer for your updated question :) Note that merge queries have been redesigned late in the D7 development cycle to actually work like MERGE sql queries, which are part of the SQL 2003 standard but no dbms actually implements it yet, so all dbms require two queries (they are made atomic by using transactions). The problem with the single query approach which was used for MySQL was that it completely ignored the key() definition and simply worked with the unique/primary keys of a given table.
Comment: @Berdir: Thanks for pointing me in the right direction. I'm one of those developers who like to write SQL and have a hard time getting used to the new db API :)
Comment: Thanks for this pointer. However, I had to resort to db_query anyways as the Drupal db api does not allow using constants like CURRENT_TIMESTAMP (see http://drupal.org/node/215821)


Automatically show one selection of a field based on the selection of another field in a view

Question: Sorry if this is a repeat question but I'm stuck!
Ok, I have a content type named 'Media' that is basically a bunch of videos, pictures, podcasts as well as a small write up that explains what it is. I have a view that lists these media files according to most recently added. My problem is that in this view, I display an icon according to whichever type of media it is (a camera logo for videos, and podcast logo for podcasts, etc.) but I have to choose which one it is every time I create a new 'Media' content type.
I have a field called 'icons' within this 'Media' content type, which is just a term reference with a select list widget. The taxonomy terms are the file types (video, podcast, picture) and they are linked to the correct image/logo/thumbnail whatever you want to call it.
What I want to do is have it so that when I am adding a new 'Media' content type, it will automatically figure out the correct image/logo to display once I select the type of Media it is (the 'type' is a list(float) field and also uses a select widget). I hope this makes sense!
Comment: if I understand the question properly, you should be able to create a relationship to the term reference field, thereby being able to include the image/logo/thumbnail directly as a field in the view
Comment: Oh, so thaat's what relationship is for! Wow, I will have to read and figure out how to do that, thanks!
Comment: relationships are quite powerful - they let you connect data about a node to the author for example, basically any other data elements within the node, user or whatever the view shows, so long as there is some connection - in your case a term reference which needs to be accessed on its own accord because it is essentially its own node and data structure, which is why it doesn't necessarily show as a field of its own until the relationship is established
Answer: Take a look towards conditional fields module. Hope this will helps to solve your issue.
(https://www.drupal.org/project/conditional_fields)


UITableView: Set table header view height based on screen size

Question: I have a table view with a table header view created through interface builder inside the same xib. I want to set the height of the header based on the screen size, for example 50% of the screen height.
Here is what I get with a static height on an iPhone 4s:

And here is is what I get on an iPhone 6:

Note that the content of the header is static.
I cannot set constraints to the header using auto layout. I tried to set a height constraint based on the height of the table view but it does not seem to be possible in interface builder. Control-dragging does not work. I cannot drag a line from the header to the table view or even to the header itself.

How can I set the header's height based on the screen size?
Comment: Add a height constraint for the header view in interface builder and CTRL Drag it into your header file to create an IBOutlet. In viewDidLoad, set the value of the constraint to `yourOutlet.constant=[[UIScreen mainScreen] bounds].size.height/2`. On rotation, you will need to also reset the constant.
Comment: Thank you, but I can't added a constraint to the uiview  header view, I have updated the question and attached an image please take a look at the "Edit" section of my question
Comment: Yes, seems there are issues using constraits on the table header. Have posted a simple working solution for you.
Answer: Unfortunately, table header views cannot be sized using auto layout. You can use auto layout for elements inside the header but you have to specify the header's size by explicitly setting its frame. If the header's height is static and known at compile time you can use IB. However, if the height is dynamic or depends on the device (as in your case), you have to set it in code.
A quite flexible solution would be to create a custom subclass of UITableView and adapt the header's frame in the layoutSubviews method. This way the header's size gets automatically adjusted when the table view is resized. You have to be careful, however, to only re-apply the header's frame when a change is actually needed to avoid an infinite loop.
Here's what it would look like in Objective-C:
@interface MyTableView : UITableView
@end

@implementation MyTableView : UITableView

- (void)layoutSubviews {
    [super layoutSubviews];

    if (self.tableHeaderView) {
        UIView *header = self.tableHeaderView;
        CGRect rect = CGRectMake(0, 0, self.bounds.size.width,
                                 self.bounds.size.height / 2);

        // Only adjust frame if needed to avoid infinite loop
        if (!CGRectEqualToRect(self.tableHeaderView.frame, rect)) {
            header.frame = rect;

            // This will apply the new header size and trigger another
            // call of layoutSubviews
            self.tableHeaderView = header;
        }
    }
}

@end

The Swift version looks like this:
class MyTableView: UITableView {

    override func layoutSubviews() {
        super.layoutSubviews()

        if let header = tableHeaderView {
            let rect = CGRectMake(0, 0, bounds.size.width, bounds.size.height / 2)

            // Only adjust frame if needed to avoid infinite loop
            if !CGRectEqualToRect(header.frame, rect) {
                header.frame = rect

                // This will apply the new header size and trigger
                // another call of layoutSubviews
                tableHeaderView = header
            }
        }
    }

}

Note that the above snippets use the bounds of the table view rather than the screen size to calculate the header size.
Update: Note that sometimes an additional call to layoutIfNeeded is needed after setting the tableHeaderView property. I ran into an issue where section headers were drawn above the header view without calling layoutIfNeeded.
Answer: I have tried the following code and it seems to work on iOS7 and iOS8. It changes the height of the header frame to half the screen height. You might want to subtract the height of the navigation and status bar from the screen height before /2, if the header has to be half the size of the table view area only.
- (void)viewDidLoad
{
    [super viewDidLoad];

    // Your other code

    // Set the table header height
    CGRect headerFrame = self.tableView.tableHeaderView.frame;
    headerFrame.size.height = [[UIScreen mainScreen] bounds].size.height/2;
    self.tableView.tableHeaderView.frame=headerFrame;
}


Como mudar a cor da pipe no NETBEANS?

Question: Eu estava mudando as cores do editor do NETBEANS , só que eu não consegui mudar a cor da pipe (a barra que aparece quando você vai escrever algo). Vocês podem me ajudar ?
Answer: Olá, tente Ferramentas/
Opções/
Fontes e Cores/
Aba Realce/
Cor do Cursor/
E é isso aí, só mudar para uma cor que contraste com o fundo da sua tela
Comment: Opa , obrigado pela ajuda , resolveu bastante coisa .

Como mudar a cor da pipe no NETBEANS?


Ubuntu server as DHCP Server and Internet Gateway

Question: In my work environment there is one ubuntu server (dynamic ip) and 6 win7 systems all connected to a switch which is connected to a modem(isp internet). Right now the modem acts as dhcp server and assigns ip for all the systems including ubuntu server.
I wanted to use my ubuntu server as DHCP server and assign ip and provide internet all other win7 systems. What should i do inorder to make this kind of configuration ? I know many workspace and schools follow this configuration.
I know i have to install dhcp server in ubuntu but after that i have no idea about configuration. I have ordered for static ip only for my ubuntu server.
My question is can i make my ubuntu server as my internet gateway and provide internet access to all other systems so i can also install firewall in the server. What is the exact configuration please guide me. Right now ubuntu server has dynamic ip is it possible now ?
Answer: Yes you can, Linux has very extensive network capabilities.
As for configuration, Ubuntu guides are quite good: https://help.ubuntu.com/community/Router
I'd also recommend reading about Linux (Introduction to Linux - A Hands on Guide) and Linux System Administration (The Linux System Administrators' Guide) at http://tldp.org/guides.html to get a wider picture.
Answer: Yes it is possible. I would suggest looking at dnsmasq for your DHCP and DNS requirements, and Squid as your proxy server if required.


Prevent animated background image in pseudo ::before element from being cropped

Question: I am trying to have the background image of a div animate in scale and rotation, and have semi-achieved this using a pseudo ::before element of the div, and having the background image on that element. The problem is that I can't seem to get the text in the orginal div to present in front of the animated background, and also i am having weird issues with the graphic being cropped to the dimensions of the final div size.
Its hard to explain but you can more easily see in my demonstration jsfiddle here!
Here is my html:

I want this title to stay in the foreground

And here is my css:
body {
background-color:#333;
}

#box {
z-index:2;
width:700px;
height:200px;
border:3px solid #e7f26d;
position:relative;
text-align:center;
color:#000;
}

#box * {
z-index:2;
}

#box::before {
content:"";
z-index:1;
position:absolute;
top:0;bottom:0;left:0;right:0;
background-image:url('https://www.picpng.com/image/view/110525');
background-image:no-repeat;
background-position:center;
-webkit-animation:grow-rotate 4s linear normal;
}

@-webkit-keyframes grow-rotate {
0% {transform: rotate(320deg) scale(0);}
100% {transform: rotate(360deg) scale(0.2);}
}

The multiple problems i am trying to solve are:
1. MAIN PROBLEM Prevent the background graphic form being cropped. The image is a
    spiral/circular, and i want to see the full spiral until it reaches
    the edges of its parent. So, ultimately it does get cropped when it
    reaches the container div boundaries, but not whilst it's scaling
    up. Is this even possible? I have tried various combinations of
    overflow properties, but i must have position:relative on the #box
    div.
2. Does the final degree of rotation have to be its finishing
    point? i only want to turn the image about 40 degrees from start to
    finish, but i don't want a sudden jump at the end to its starting
    point, hence why i start the rotation at 320deg and finish at
    360deg, so there isn't a sudden jump at the end. Albeit this isn't
    working here either.For some reason its jumping at the end to full scale.
3. keep the h1 title text in front of the background graphic
Apologies if this is too many problem points for one question. Number 1 is my primary problem right now. Thank you to anyone who may be able to help me figure some of this out.
Answer: Here is the solution
Cropping Issue:
Try to make the :before element to square using top and bottom negative values and use background-size:contain(It will remove your cropping issue)
Heading Issue:
Set z-index:-1 to the :before pseudo class.
Jumping Issue
Set your animation-fill-mode: forwards
Updated Fiddle
Comment: @user2998925 1)square: because your block have width 700px so I made the `:before` to 700px in height...2)..if you want your scale value to change other than 1 you have to change your animation-direction:forwards which is normal now....Updated to scale(0.5) and direction forwards.....check updated fiddle...
Comment: @user2998925 set top and bottom value higher to -99999px....and apply `backgound-position: center center` so that your background always stay at center...
Comment: Oh wow. Suddenly so beautiful. thank you! :)

May i ask a couple of questions:

1) how did you decide on the size to make the square? was it based on eth size of my PNG image?

2) I see you changed the final state of the scale to a complete full scale (1). What if i only want the final scale to be 0.5, when i do this, it always suddenly jumps to full scale at the end. Do you know why?
Comment: amazing - THANK YOU! and one final question... what if the width of my #box div is dynamic (a row in bootstrap), how would i know what negative margin to give?
Comment: Thanks so much Bhuwan for your help. I greatly appreciate it!


Determining automorphisms of this extension

Question: I'm having a bit of trouble understanding an example from the introduction to galois theory section from Gallian's text.
We have that $\omega = -1/2 + i\sqrt 3/2$ satisfies the equations $\omega^3 = 1$ and $\omega^2 + \omega + 1 = 0$. We now consider the extension $Q(\omega,2^{1/3})$ of $Q$.
I understand that any automorphism of a field containing Q must fix Q, and since the basis of the extension field will involve powers and products of $\omega$ and $2^{1/3}$, we just need to find out where the automorphisms send those elements.
What I don't understand is how we determine that there are six possible automorphisms and where they send these elements. The automorphisms he lists in the text send
$\omega \to \omega$ or $\omega^2$
and $2^{1/3} \to 2^{1/3}$ or $\omega(2^{1/3})$ or $\omega^2(2^{1/3})$.
I'm just having a bit of trouble seeing how he determined where the automorphism sends the elements, I suspect it has something to do with the basis of the extension? But I'm not sure.
In a previous example when we had the extension of $Q(\sqrt 2)$ over $Q$, the automorphisms could send $\sqrt 2$ to $\pm \sqrt 2$ since
$2 = \phi(2) = \phi(\sqrt 2 \sqrt 2) = (\phi(\sqrt 2))^2$
In this case the basis of the extension is $\{1,\sqrt 2\}$, so we're not just sending the basis element $\sqrt 2$ to another basis element, rather its conjugate.
I'm guessing there's a fundamental misunderstanding I'm having about determining the automorphisms.
Thanks
Comment: Any automorphism sends an element to its conjugates. That's how author is determining those automorphism. Also if you are familiar with Galois extensions and splitting fields , in this case you can determine the order of group of automorphisms (Galois group) without explicitly calculating the maps.
Comment: As @skmehta says, $\omega$ must go to a root of $X^2+X+1$, and your chosen cube root of $2$ (you've called it $2^{1/3}$) must go a root of $X^3-2$. There's your six members of the Galois group.
Answer: The extension $\Bbb Q(\sqrt[3]{2},\omega)$ is the splitting field of the irreducible polynomial $x^3 - 2 \in \Bbb Q[x]$. It is not hard to see that:
$x^3 - 2 = (x - \sqrt[3]{2})(x - \sqrt[3]{2}\omega)(x - \sqrt[3]{2}\omega^2)$
that is, each of: $\sqrt[3]{2},\sqrt[3]{2}\omega,\sqrt[3]{2}\omega^2$ is a cube root of $2$.
Part of the behavior of the Galois group of $x^3 - 2$ has to do with the "threeness of three", an odd degree rational polynomial has either one, or three real roots. This is because complex-conjugation (the algebraic closure of $\Bbb Q$ is a subfield of $\Bbb C$) is a field automorphism of $\Bbb C$ that fixes the reals (and thus the rationals).
In this case, we have the partial factorization over $\Bbb Q(\sqrt[3]{2})$:
$x^3 - 2 = (x - \sqrt[3]{2})(x^2 + \sqrt[3]{2}x + \sqrt[3]{4})$
and we have "two types" of automorphisms of $\Bbb Q(\sqrt[3]{2},\omega)/\Bbb Q$: ones that send all three roots of $x^3 - 2$ "in a circle" (cycle), and ones that swap just two of them (with a quadratic only the second type is possible).
Since we have 3 roots, we have "some" subgroup of $S_3$, and since this group has a 3-cycle AND a two-cycle (we know it has a two-cycle, because the restriction of complex conjugation to $\Bbb Q(\sqrt[3]{2},\omega)$ is obviously an automorphism of $\Bbb Q(\sqrt[3]{2},\omega)/\Bbb Q$ of order 2), it must be $S_3$. From here it's just a matter of "back-figuring" what each permutation of the roots must do to the generators. That is:
$\text{Gal}(\Bbb Q(\sqrt[3]{2}/\Bbb Q) = \langle \sigma, \tau\rangle$ where:
$\sigma: \sqrt[3]{2}\mapsto \sqrt[3]{2}\omega \mapsto \sqrt[3]{2}\omega^2 \mapsto \sqrt[3]{2}$
$\tau: \sqrt[2]{2}\omega \mapsto \sqrt[3]{2}\omega^2 \mapsto \sqrt[3]{2}\omega$.
The roots of $x^3 - 2$, when plotted on the complex plane, form the vertices of an equilateral triangle, making it appear less mysterious that their symmetry group is the symmetry group of said triangle.