iphone - coredata application directory

Question: I am using this Xcode template for core data.
On the delegate, I have this method:
<code>- (NSURL *)applicationDocumentsDirectory {
  return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
</code>
but this requires iOS4.
I am trying to make the app compatible with 3.0.
So, I have converted this method to:
<code>- (NSURL *)applicationDocumentsDirectory {

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  return [NSURL URLWithString:documentsDirectory];

}
</code>
but when coredata tries to use the store URL on
<code>  NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyFile.sqlite"];
  if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
</code>
it crashes on the IF line with the message:
CoreData SQL stores only support file URLs (got /var/mobile/Applications/BB312A7E-6AE1-4BA2-AD87-6B96D8855CC6/Documents/MyFile.sqlite).'
but StoreURL is a NSURL!
Any clues? Thanks
Answer: Try doing:
<code>NSString *pathToYourSqliteFile = @"/your/path/here";
NSURL *storeURL = [NSURL fileURLWithPath: isDirectory:NO];
</code>
See if that does the trick.
Comment: My Apps Deployment target is 8.0 and this worked for it! Thanks!
Answer: See CoreData application directory crashes on iOS3
The suggestion from Surfdev works ok on 3.1.2
Answer: Swift 3
<code> let documentsUrl = FileManager.default.urls(for: .documentDirectory, in:.userDomainMask).first!
</code>

iphone - coredata application directory


"Crescendo" vs hair pin

Question: symphony no.1 movement 1 page 16 by the string sections
Working on Peter I. Tchaikovsky first symphony manuscript conductor's score. I came to an interesting observation.
On the same page all instruments start with a P (piano) then a few measures later get louder to an F (forte) the difference is that for some instruments he added an expressive, crescendo mark, while some he use's an opening hairpin. I would like to know if there is a difference between the two? If not why does he use it for one instrument yes, and other instruments no?
The symphony is no. 1 first movement around  page 16. To get to look on the manuscript you can go to imslp Tchaikovsky symphony no1 opus 13.
Comment: @guidot, There is a difference between the use of hairpins and the word 'crescendo'. Historically, they did not have the same meaning. In the first chapter of the book 'The secret life of Musical Notation' (Roberto Poli), the author explain how hairpins, in some old works (as the ones of Chopin, for example), where used to mark speed changes in a musical line. Because of the time when this symphony was written, I think they can mean something else, but this need to be deepened.
Comment: Can we get a picture? Hard to analyse the score without the score.
Comment: I'm not aware of any difference in meaning. Typically, if one has a (de-)crescendo over many bars, hair pins are easier to stretch than the word. But here, where the same number of bars is concerned it looks arbitrary (if not inconsistent). Given that the first violins have the word and all other strings the hair pins excludes a relation to instrument type.
Comment: I tried to download it doesn't go. I still not so good in this. I'll try again.
Comment: On IMSLP, there's only the 'Moscow: P. Jurgenson's' editions. Do you have other editions? Or better, do you have the autograph score? It would be helpful.
Comment: I added the page the link is on top.
Comment: @guidot that's all I got.
Comment: If one assumes (yeah, I know... :-) ) that the hairpin vs word was deliberately done, I'd say the hairpin was chosen for lines where there's a continuous phrase, while the words were chosen to cover a series of notes well-spaced with rests.
Comment: This is good for the whole orchestra. The first violins dosen't have any rests and the is expressive text not a hairpin?
Answer: I think this is an error in the score. If I say that, it's because Thcaikovsky, in a letter to Jugensern (the editor of the score you are working on), say that few mistakes are still present in the score.
I found this on the internet:

Tchaikovsky gave a detailed account of his reworking of his First Symphony, and publication of the full score, in a letter to Pyotr Jurgenson of 15 April 1886:
'' It was written in 1866. For its performance I made some changes to it on the advice of Nikolay Grigoryevich, in which form it was performed in 1868. But then I decided to make some fundamental revisions to it. However, I did not carry out this intention until 1874. In 1875, on my birthday, you surprised me by presenting me with a printed copy of the full score. I was touched by your kindness, but very displeased with the numerous errors which spoiled the edition. But mistakes aside, the symphony was printed correctly, i.e. with changes to the theme that I made in 1874. Then it was not played until 1883. Before the performance, Albrecht sent the full score to me at Kamenka. I noticed many mistakes, and during rehearsals Erdmannsdörfer found many more, but everything was performed correctly. Then you wanted to publish a new piano arrangement of the symphony, and commissioned Langer to do it, which was a bad idea. He made this with Kashkin's help, and I checked it (during rehearsals for Mazepa, i.e. at the end of '83 and beginning of '84).
What has happened to all these?: i.e. the full score with my corrections, and Erdmannsdörfer's on the parts, used for rehearsals, and the piano arrangement—they all seem to have disappeared without trace. Now, a month or so ago, you asked where were the revisions I'd made to the First Symphony? I explained to you that there were no revisions, and that there were only corrections to the score printed in 1875, made by myself and Erdmannsdörfer. Now what do I find? You've sent Ivanov the First Symphony with insertions here and there, which I removed during my fundamental revision in 1874; i.e. all the rubbish I threw out, you have now painstakingly restored. Where did you get these discarded passages? Who's trying to annoy me? And why did you send the parts for the later version, thus contradicting the full score which had the symphony in its original form...?
And so, to clear up once and for all the state of affairs regarding my long-suffering symphony, I say again:
1) The full score of my symphony as it stands contains countless errors.
     2) There should be the parts used by Erdmannsdörfer for the performance of the symphony in 1883. I don't know where they are, but they don't appear to be the ones you've now sent to Ivanov.
     3) The [piano] arrangement was made very badly, and printed with dozens of careless mistakes.
All these were corrected in 1883 and '84, but I don't know where the proofs are now.
4) The handwritten sheets, enclosed with the proofs you sent to Ivanov, quite outrageously contain everything I threw out in 1874, and which, for reasons incomprehensible to me, you saw fit to restore.''

To support this answer, I also had a look in some individual parts. I found that in the bass and second violin parts (I only had a look to the strings section), the publisher used this notation (instead of what was in the score):
Bass part:

Second Violin part:

instead of this score part :

Viewing that, one can suppose that there is a mistake in the score (or in the part). I think to resolve this question, you will have to access the real score of this symphony with the annotated by the composer (because the autograph score seems to be lost).
Comment: But because this work is old, maybe you have to research in the significance of hairpins in romantic works... You can maybe try to read the Roberto Poli work's mentioned above.
Comment: If you say it's a mistake on the part of the publisher, that's ok with me. But the second part of the question is there a difference, wasn't answered.
Comment: Welcome to the site. i hope we can rely on further great answers in the future.
Comment: I started to answer this above (in a comment to guidot). In my university percussions classes (Université Laval), I learn that the difference between the two, nowadays, is that the hairpins are use to have a gradual increase in dynamic and the word crescendo is use to ask a more retarded increase in the dynamic (you have to wait a bit before increasing more quickly). I don't know if you understand what I mean (english is not my language, so I have difficulties to explain it).
Answer: Yes, there's a difference.  I do mostly re-engraving of very old out-of-print public domain works from obscure sources sometimes, and as Tchaikowsky was well aware, engravers used to, and still do, take incredible liberties - myself included!  However, I understand the conventional interpretation is that "cresc." and "dim." means "start changing the volume, and keep doing it until I tell you to do something else", and a hairpin up or down is a clear indication of how long the change in volume is to take.  Hence if there's a volume change required over many bars (good ol' Rossini overtures!), you'd write "crescendo" or perhaps "poco a poco cresc." or "molto cresc.": and then write in the finishing dynamic where it is required.   A hairpin drawn over a large number of bars just doesn't work visually.
Another thing that's argued about constantly is how to interpret fp and pf!  One thing's for sure, pf doesn't mean start softly and suddenly get louder!
Interesting thread!
John.
Answer: I am both a flutist and vocalist in the USA and it looks to me like the score has the word "crescendo" written across many bars for some instruments and then the hairpin symbol referring to "crescendo" under other instruments. I don't believe there is a difference in the speed at which the crescendo would be performed by the orchestra as a whole in this case, regardless of how the crescendo instruction is notated. Hope this is helpful!
Answer: The hairpin in old music is used as a rhythmic device (rit/accel) or agogic accent.  This is discussed at length in Roberto Poli's book, "The Secret Life of Musical Notation."  At some point early in the 20th century this changed. In very small circles this knowledge is known, but most musicians are largely ignorant of the practice.
Answer: I cannot say for this piece in particular, but just want to mention that during the romantic era, hairpins was also used to denote a type of rhythmic flexibility and rubato. That is, in contrast to the traditional interpretation as crescendo and diminuendo.
In this fantastic Youtube video where Seymour Bernstein goes through Chopin's Prelude in E minor he mentions this point, and also shows some documentation to back up this interpretation of hairpins. For instance:

The sign <>, as used by Brahms, often occurs when he wishes to express great sincerity and warmth, applied not only to tone; but to rythm also. He would linger not on one note only, but on the whole idea, as if unable to tear himself away from its beauty.

(Stated to be from "Cobbett's encyclopedic survey of chamber music")
Another quote is:

The <> sign stands for accelerando and ritardando. The instruction is striking on several accounts. First the performer is to interpret the tempo flexibly, presumably in a type of rubato - the rhythmic groupings are not literal, but elastic, now pressing forward, now restrained. Traditionally used to control dynamics, the hairpins regulate instead a constantly shifting sense of rhythmic energy and abatement.

(Quote attributed to Fanny Mendelssohn)
Maybe more to the point is this research paper "The Brahmsian Hairpin" by David Hyun-Su Kim (19th-Century Music
Vol. 36, No. 1), which describes different interpretations of hairpins across time.
Abstract:

Hairpins, the notation symbols < and >, are today universally accepted as equivalent to the markings crescendo and diminuendo, calling for an increase or decrease in volume. This view is irreconcilable with the scores of the core German repertoire of the nineteenth century. This article offers a new understanding of hairpins based on careful examination of the scores of Brahms and of early-twentieth-century recordings by artists close to him. In Brahms's milieu hairpins did not prescribe sounds, but rather described meanings. The difference between prescription and description is central, suggesting that instead of "growing louder/quieter," hairpins are better understood as "becoming more/less." The means by which "more/less" was realized by nineteenth-century musicians included many techniques beyond dynamics, most notably agogic inflection.

"Crescendo" vs hair pin


Google chrome not open when vs code launch

Question: I have some trouble with Visual studio code extensions.
When I click on extension "open in default browser" the error below is shown.
If I click on "live server", Google Chrome wont launched either.
Recently I installed Java and this extensions stopped working.
Answer: I was having this same issue with the "open in browser" extension. I clicked on the settings icon and installed an older version 1.1.0. Its working again for me.


Why are my COM ports busy?

Question: I have a python program I am using to talk to a microcontroler. It opens the com ports like this:
def STM32_connect():
    ports = list(serial.tools.list_ports.comports())
    for p in ports:
        if "STM32" in p.description:
            connection = serial.Serial(p.device, timeout = .01)
            return(connection)
    print("ERROR: No STM32 Device Found")
    sys.exit()

serial_connection = STM32_connect()

And then does a bunch of things, sending and receiving data until I close the program like this with a keyboard interput:
except:
    print("\n Program Interrupted...")
finally:
    print("\n Closing Serial Port\n")
    serial_connection.close()

This all works fine. My problem is when the python script is improperly killed by disconnecting the USB cable or powering off the board I can no longer connect to the micro on any COM port. I receive this error:
Traceback (most recent call last):
  File "/home/---/.local/lib/python3.5/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 16] Device or resource busy: '/dev/ttyACM2'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "flextester.py", line 1, in <module>
        from flex_usb_class import *
      File "/home/---/Code/RobotFlexTester/flex_usb_class.py", line 30, in <module>
        serial_connection = STM32_connect()
      File "/home/---/Code/RobotFlexTester/flex_usb_class.py", line 25, in STM32_connect
        connection = serial.Serial(p.device, timeout = .01)
      File "/home/---/.local/lib/python3.5/site-packages/serial/serialutil.py", line 240, in __init__
        self.open()
      File "/home/janey/.local/lib/python3.5/site-packages/serial/serialposix.py", line 268, in open
        raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
    serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyACM2: [Errno 16] Device or resource busy: '/dev/ttyACM2'

I can change COM ports and I receive the exact same error at a different ttyACM port. But I can connect to the same device on the same port if I try to run a different python script. The problem seems to somehow be locked to the initial test script but ps -a does not show it to still be running. The problem goes away without me doing anything after about 30 seconds - 1 min.
Answer: the 30s to 1min delay are due to the internals of RS232 protocol. see the closing_wait option ( default 30 sec ) in setserial command ( http://manpages.ubuntu.com/manpages/zesty/man8/setserial.8.html ) when disconnecting USB cable and connection is killed the protocol waits for the time specified in the closing_wait option until it closes the port / session.  session_lockout forbids attaching a second process to an open port...

Why are my COM ports busy?


UIPasteboard.generalPasteboard in Action Extension

Question: I've been working on an Action Extension since beta 1. It is a URL shortner via bitly.com. When the URL is shortened it is copied to the user's pasteboard
UIPasteboard.generalPasteboard().URL = shortUrl
This was working fine the last time I checked in beta 5. As of GM it seems we no longer have access to the pasteboard?
po UIPasteboard.generalPasteboard().URL
Returns nil in scenarios that I know there is something there, and when I verify that shortUrl indeed contains a value, the assignment is ignored. Printing UIPasteboard.generalPasteboard().URL always returns nil while debugging the extension.
Was access to the pasteboard removed? It seems to be a silent failure if so.
I have also reproduced this in Objective-C, so it is not a Swift issue.
Update
I tried this in an extension that has user interface (there are two types of action extensions, those without and those with). For those with UI, the pasteboard works as expected. So this seems isolated to action extensions without UI.
I also reported a bug on this.
Update 2
I believe this to be a bug, Apple closed my radar as a duplicate.
Comment: I tried this in iOS 11 and it worked fine in both kinds of action extension. So if this was a bug, it is now fixed; action extensions are allowed to set the pasteboard.
Answer: I'm running into the same issue as well.  I'm using it in objective-C though.  Tried the pasteboard in it's simplest form and still nothing.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setString:@"copied string"];

The above code works fine in the containing app though.
Update:
For those still searching for an answer and wanting to use the pasteboard with the custom keyboard extension, I came across this post: iOS8 Custom Keyboard - Copy & Paste to UIPasteboard
You will need to allow BOTH full access in your plist file and allow full access in the keyboard settings in the Settings.app.
Comment: @Chris I'm using the keyboard extension but have the same issue.  Something I noticed to is that it's working fine in the simulator, just not on a device.  It very well might be a bug.  I'll file a bug report as too.

Also I'm too new to stackoverflow to comment on anyone's post except my own, :p


How to export (oracle) database table to excel sheet using laravel

Question: I am trying to export a (query structured) table (called formal) to excel using laravel. So far I can show table in browser as html using this blade. I want when user presses Export to excel button to export to excel (my blade is below):
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Studies</title>

Schedule: {{ $key }}

        Lesson Category
        Lesson Code
        Lesson Title
        Lesson Department
          /* extra columns
           ....
          */
        Audience

    @foreach($star as $v2)

        {{ $v2->lesson_category }}
        {{ $v2->lesson_code }}
        {{ $v2->lesson_title }}
        {{ $v2->lesson_dep }}
        /* extra columns
           ....
        */
        {{ $v2->audience}}

    @endforeach

<form action='/programma'>
    <input type="submit" value="New Search" />
</form>

<form action='/export'>
    <input type="submit" value="Export to excel" />   //I want this button to
                                                      //export to excel
</form>

I have followed this guide with no success.
https://docs.laravel-excel.com/3.1/getting-started/installation.html
https://docs.laravel-excel.com/3.1/exports/
The maatwebsite/excel has been installed successfully. But no excel is downloaded.
Comment: Please can you show the controller code for the `/export` route?
Comment: What error do you get after calling '/export' ? Do you have all required extensions enabled server-side?
Comment: Hi guys! I finally did it, but there is still a problem. The exported excel does not have titles on top of each columns. Could you help me a little bit? I will answer my question myself and any idea is very very welcome!
Answer: The problem is solved. I did it to export to excel file.
Below is my solution so far. Thank you all!
1) web.php
Route::get('/exagogi','UsersController@export');

2) UsersController.php
<?php namespace App\Http\Controllers;

use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class UsersController extends Controller
{
    public function export()
    {
        return Excel::download(new UsersExport, 'result.xlsx');
    }
}

3) UsersExport.php
<?php

namespace App\Exports;

use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class UsersExport implements FromCollection, WithHeadings
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return User::all();
    }

    public function headings(): array
    {
        return [
            'Lesson Category',
            'Lesson Title',
            'Lesson Department'
        // etc

        ];
    }
}


Slight generalisation of the distribution of Brownian integral

Question: I think I have seen once that if the processes $\sigma$ and $W$, a Brownian motion, are independent then one has that
$$
E \left[\exp \left(iu\int_t^T \sigma_s \, dW_s\right) \mid \mathcal{F} \right] = E\left[\exp \left(- \frac{1}{2} u^2 \int_t^T \sigma_s^2 \, ds \right) \mid \mathcal{F} \right]
$$
for $\mathcal{F}$ the $\sigma$-algebra generated by $(\sigma_s)_{ s \leq T}$. I am not sure the formulation is completely correct though, it is purely from memory.
Is this true? - could one help with a reference?
If $\sigma$ is of bounded variation, is it then true that the integral can be defined without use of the the whole usual "limit in $L^2$ construction" of the stochastic integral. If so what is a reference for that?
Edit: I've found a brief discussion of the second fact see here
Answer: First consider the case that $\sigma$ is a simple function, i.e.
$$\sigma(s) =\sum_{j=1}^n 1_{[t_{j-1},t_j)} \xi_j \tag{1}$$
where $(\xi_j)_{j=1,\ldots,n}$ are random variables independent from the Brownian motion $W$. Without loss of generality, we may assume that $t_k = t$ for some $k \in \{1,\ldots,n\}$ (otherwise we add the point to the partition). Then
$$\begin{align*} \mathbb{E} \left( \exp \left[ \imath \, u \int_t^T \sigma_s \, dW_s \right] \mid \mathcal{F} \right) &= \mathbb{E} \left( \exp \left[ \imath u \sum_{j=k+1}^n \xi_j (W_{t_j}-W_{t_{j-1}} \right] \mid \mathcal{F} \right). \end{align*}$$
Since $W$ is independent of $\mathcal{F}$ and $\xi_j$ measurable with respect to $\mathcal{F}$, we get
$$\begin{align*} \mathbb{E} \left( \exp \left[ \imath \, u \int_t^T \sigma_s \, dW_s \right] \mid \mathcal{F} \right) &= \mathbb{E} \left( \exp \left[ \imath \, u \sum_{j=k+1}^n y_j (W_{t_j}-W_{t_{j-1}}) \right] \right) \bigg|_{y_j = \xi_j} \\ &= \exp \left( - \frac{1}{2} u^2 \sum_{j=k+1}^n y_j^2 (t_j-t_{j-1}) \right) \bigg|_{y_j = \xi_j} \\ &= \exp \left( - \frac{1}{2} u^2 \int_t^T \sigma^2(s) \, ds \right). \end{align*}$$
For general $\sigma$, approximate $\sigma$ by suitable simple functions of the form $(1)$ and use the dominated convergence theorem to conclude that
$$ \mathbb{E} \left( \exp \left[ \imath \, u \int_t^T \sigma_s \, dW_s \right] \mid \mathcal{F} \right) = \exp \left( - \frac{1}{2} u^2 \int_t^T \sigma^2(s) \, ds \right).$$

Concerning your second question: For functions of bounded variation, a stochastic integral can be defined by integration by parts, i.e. by setting
$$\int_0^t \sigma(s) \,d W_s := \sigma(t) W(t) - \int_0^t W(s) \, d\sigma(s).$$
The integral at the right-hand side is well-define since $\sigma$ is of bounded variation. This leads to the so-called Paley-Wiener-Zygmund integral (which are a special case of the Itô integral); see e.g.
Rene Schilling, Lothar Partzsch: Brownian Motion - An Introduction to Stochastic Processes, Remark 13.5
for a (short) introduction.
Comment: Thank you very much for your answer saz. I managed to find the original source of my second question see the answer of MarkV in this link: http://mathoverflow.net/questions/42104/expectation-of-time-integral-of-wiener-process
Comment: @Henrik Ah, that's what you are after; I see. I have edited my answer.
Comment: I agree it was not clear. Thank you once again solving my ill-posed problems :)
Comment: @Henrik You are welcome.


haproxy hash that honors already connected connections

Question: We have configured haproxy 1.5 and are using map-based hash (default).
For e.g. we have two backend servers. Server A and Server B.
Clients 1,2,3,4,5 will go to same backend.
For example
Client 1,2,3 are connected to Server A as per hash.
Server A is crashed.
haproxy shifts them to Server B.
Server A recovers.
Client 4,5 are connected to Server A
Problem is that 1,2,3 remain connected with Server B but as per updated hash, they should be connected with Server A.
We want all clients 1,2,3,4,5 to be connected to same Server.
Connection remain connected for very long time so either they need to be forcefully disconnected if hash changes or hash should be such that it honors already connected connections.
What hash should we use in this case or is there any other configuration that we should be using?
Answer: Answered by Willy over mailing list.
stick tables is the feature we are looking for.


Finding J-invariant of Legendre form of Elliptic Curve

Question: PROBLEM: Put the Legendre equation $y^2 = x(x − 1)(x − λ)$ into Weierstrass
form and use this to show that the j-invariant is
j = $2^8\frac{(λ2 − λ + 1)^3}{λ^2(λ − 1)^2}$ .
Recall:
Weierstrass equation form:   E: y^2 = x^3 + Ax +B
and
J(E) = 1728$\frac{4A^3}{4A^3+27B^2}$
Attempt:
$y^2 = x^3 + (-\lambda-1)x^2 + \lambda x$
Now I'm having trouble transforming this into Weierstass form. What would be the way to go for transforming this equation? $x^2 = x_1$ would not work. Idk..
Comment: I would try $x'=u^2x+r$, $y'=u^3 y$ for some suitable constants $u,r$.
Comment: So then x = $\frac{x'}{u^2}$ and y = $\frac{y'}{u^3}$.
Plugging that in did not get that $x^2$ to disappear. I'm sure there's a simple transformation that I'm not just not thinking of. It's one of those once someone shows me I'll feel dumb.
Comment: You are to find a suitable value of $r$. It may be the case that you can assume that $u=1$, I'm not sure.
Comment: Like Jyrki says, a transformation of the form $x'=x+r$ will do the trick.
Answer: In general, if a curve is given by $Y^2=X^3+AX^2+BX+C$, a change of variables $Y=y$ and $X=x-A/3$ will provide a model for the curve of the form $y^2=x^3+A'x+B'$.
The reason is that
$$X^3+AX^2+\cdots = (x-A/3)^3 + A(x-A/3)^2+\cdots$$
and the coefficient in $x^2$ is given by $3(-A/3)+A=0$.


What's going on in this musical notation?

Question: The notation snippet below is from the cover of a Composition textbook. The cover has a pale blue background and pale green notes, so I changed it to be black on white to make it easier to read.
From the lower stave, it looks as though the time signature is 5/16
But I can't work out what's going on in the upper stave. There seems so be some sort of clash between the beams and I can't work out what that 16th rest applies to.
Can anyone make sense of it?
Comment: Since it's on cover, the obvious explanation would be that it was put together by publisher's graphic designer and authors saw it only after it was already printed.
Comment: Beautiful example how a piece of music score cut out of the context – not really your fault in this case – might be impossible to decipher.
Comment: I just noticed that on the back cover of the book there's a note that says the excerpt on the front cover is Chopin Prelude op. 28, no. 1
Answer: These are bars 10 and 11 from Chopin's first Prelude (a larger snippet from IMSLP):

Different editions vary on exactly how they place the beams - the original screenshot seems quite poorly typeset.
The time signature is 2/8; the initial three LH semiquavers form an unmarked triplet (tuplet markings are often omitted like this; the first bar has them explicitly but the remaining bars are left implicit).
The upper stave contains three voices, but the rests for some of them have been omitted to avoid cluttering the score:

the uppermost voice is silent for the first beat, and then has a triplet quaver-and-semiquaver from G to A; the triplet marking and initial rest are both omitted;
the middle voice is silent for the first semiquaver and then plays an upwards-and-downwards arpeggio of five semiquavers; these are also all implicit triplets (the first bar has explicit triplet markings)
the lowest voice is also playing a G-to-A melody, an octave lower than the uppermost voice; it starts after a (triplet) semiquaver rest and then holds the G until the final (triplet) semiquaver where it joins the uppermost voice for an A.

The (triplet) semiquaver rest applies to both the lower two voices; the upper voice's initial quaver rest is omitted.
The lowermost voice's "dotted quaver" is not actually a literal dotted quaver since it takes the span of four triplet semiquavers (4/3 of a quaver) and not the usual span of three semiquavers (3/2 of a quaver). This sort of technically-wrong notation is often used when the intent is "clear", and when the actually-correct notation would be too confusing to read quickly. (There's no "triplet-dot" notation; a double-dotted quaver would also be wrong; two tied triplet-quavers would be correct but would clutter the RH a lot and, I think, obscure the similarity between the lowermost and uppermost RH voices.)
What if we don't recognise where the music comes from?
In this case the original score tells us everything - it has the explicit triplet markings in the first bar, and the time signature - but how might you figure this out if you don't know what piece the original screenshot is taken from? There is just about enough information in the bars given to make a decent guess, I think.
The top G in the RH lines up with the LH quaver rest, indicating that they probably occur at the same point in time. The LH is grouped into two chunks (a set of beamed semiquavers, and a rest) and the middle voice in the RH has a beam-break in its semiquavers at that point, strongly suggesting that the LH quaver rest, and the second half of the RH bar, form a new beat. (From the left hand, therefore: probably two beats in the bar?)
From the LH, this beat is one quaver long, and the RH middle voice fits three semiquavers into this time period - which points to either an unmarked triplet in the RH, or an unmarked duplet rest in the LH. There's definitely something tuplet-related going on, though.
So, ignoring the RH lowermost voice for the moment, we're probably looking at one of:

a piece in 2/8, with unmarked triplets
a piece in 6/16, with unmarked duplet rests in the LH (?)
a piece in 5/16, with some unmarked triplet semiquavers alongside equally-unmarked regular-semiquavers-in-groups-of-three

Unmarked triplets in piano music are very common, so the topmost of these is quite likely; unmarked duplets and unmarked tuplet rests are pretty rare, so the second is unlikely.
I think the third is also quite unlikely - a piece with both triplet-semiquavers and normal-semiquavers-beamed-in-threes would probably specify the triplets explicitly everywhere for safety - but not impossible. (I could see a piece notated with a time signature of (3+2)/16, with frequent triplets in the second beat in one voice, leaving those triplet markings implicit after a while and relying on the established pattern to "make things clear".
So: most likely in 2/8 with unmarked triplets, but possibly a 5/16 with some unmarked triplets notated in an unfriendly way.
Turning back to the initial semiquaver rest in the first half of the bar: it, followed by the two semiquavers in the middle RH voice, line up perfectly with the LH semiquavers, suggesting that it goes with those (either as an unmarked triplet, in the 2/8 case, or as literal semiquavers, in the 5/16 case). The bottom-most RH voice shares its first notehead with the middle voice; it's reasonable to assume it's also sharing the rest.
The topmost RH voice comes out of nowhere in the middle of the bar and should have a corresponding rest for the first half of the bar - but I think it's clear enough from how the voices line up vertically that that's what's happening. (If that rest was present, it would settle the 2/8-vs-5/16 issue, since we'd expect it to be a quaver rest in the first case and a dotted-quaver rest in the second case.)
The RH lowermost voice is a problem either way: regardless of how you try and interpret the other voices, the lowermost voice doesn't add up, so we don't really have any choice but to shrug and assume it's a "technically-incorrect, but clear enough in context" notational convenience and leave it out of our analysis - and, indeed, even with the original score, the lowermost RH voice is just as problematic to interpret literally.
Comment: (Also, there's a few bars later on where the RH instead plays a semiquaver 5-tuplet across the whole bar, instead of six triplet semiquavers, and I think "5-tuplet semiquavers across 2/8" would probably be more popular than "5-tuplet semiquavers across 6/16".)
Comment: Is there any obvious reason why the piece is notated in 2/8, when (from the section shown) I'd naively expect it to be more straightforward in 6/16, avoiding all the triplets?
Comment: To me, though, I think 2/8 makes sense: 6/16 would suggest something slower - to me, 6/16 is "two beats, divided into three parts each, where you can feel all six notes", whereas 2/8 here is just "two beats". The tempo marking and performances don't really allow you to emphasize the individual triplet semiquavers - they come across more as a wash of notes, and the fact there are three of them at a time feels more incidental to me, rather than something fundamental to the pulse?
Comment: Brilliant! It never occurred to me that the music contained triplets with the '3' omitted. The score snippet you posted makes it much clearer.
Comment: I don't know if the 2/8-vs-6/16 question would be entirely answerable without some input from Chopin, but I'm not sure "avoiding the triplets" would be a likely reason: notationally the triplets are 'avoided' in 2/8, because they're left implicit, and triplets are absolutely commonplace and not something that composers or performers prefer to 'avoid' anyway.


Magento 1.9 Change Order Status Uncaught Exception

Question: I am using Magento 1.9 and have an external application that takes care of shipping. Once the product is shipped a file is sent back to a listener I have written for Magento. I need to update the Magento Order status to complete and am using the following code which  is based on earlier postings on Stackoverflow
<code>$order_num = Mage::getModel('sales/order')->load($id);

$order_num->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
</code>
I am running into a problem here with the following
<code>Uncaught exception 'Mage_Core_Exception' with message 'The Order State "complete" must not be set manually.
</code>
From what I can find this is because the order state is protected.
I have spent most of the day looking at possible solutions and can not work out how I can change the order status to complete and not throw the error.
I would appreciate it if anyone could give me a clue how to get this to work for 1.9
Regards
Richard
Answer: use this code. it is works for me..
<code>$order_num->setData('state', 'complete');
                      $order_num->setStatus('complete');
                      $history = $order_num->addStatusHistoryComment('', false);

                      $history->setIsCustomerNotified(false);

                      $order_num->save();
</code>
Comment: Careful, state is to be used internally by Magento.


Updating custom module

Question: I created custom module and I installed it on "Add Module" page. I've got that module in sites/all/modules. I changed that module (I went to that location and I recoded it). What should I do to update that module. It seems to me that only after recoding that module Drupal doesn't notice changes.
Comment: Did you clear your cache?
Answer: When you edit an installed and enabled module, Drupal will not notice you added new hooks, since the list of the hooks implemented by a module is cached from Drupal. In order to make Drupal notice you edited the module and added new hooks, you need to disable and re-enable the module, without uninstalling it.
The reason why this is necessary is that module_implements(), the function that returns TRUE when a module implements a hook, contains the following code.
  // Fetch implementations from cache.
  if (empty($implementations)) {
    $implementations = cache_get('module_implements', 'cache_bootstrap');
    if ($implementations === FALSE) {
      $implementations = array();
    }
    else {
      $implementations = $implementations->data;
    }
  }

Updating custom module


inserting datetimepicker value to SQL Server 2008

Question: I'm trying to insert a value from a datetimepicker value to a SQL Server table.
My table looks like this
Profile (Id, Name,..., DateofBirth(date)...)

I have tried this to convert datetime picker value to
string dt = dateTimePicker.Value.ToString("yyyy-mm-dd hh:MM:ss");

Insert into profile (id, DateofBirth)
values(id,  CONVERT(datetime, CONVERT( varchar(11), dt, 101));

also use this
var date = new DateTime(dateTimePickerText);

also use this
DateTime date = DateBox.Value.Date;
string sDate = date.ToString("dd-MM-yy", System.Globalization.CultureInfo.InvariantCulture);
DateTime dateInsert = Convert.ToDateTime(sDate);

but can't able to insert the date into the database. 2nd how can I retrieve back the date from database?
Comment: 1) what is the error message? 2) execute a sql SELECT.  That's probably not the kind of answer you are looking for, but I can't imagine what are you looking for.  Can you be more specific about your problem "how can I retrieve" ?  Are you using a SQLCommand object, or Linq, or dataset? Details, please.
Comment: Date is saved to the database using cmd.Parameters.Add("@DateofBirth",SqlDbType.DateTime).Value=dateTimePicker but now i want to retreive it back and dolike this if(dateStored=datetime.now()) how can i do it?
Answer: You must have to use SqlParameter.
 sql="Insert into profile (id, DateofBirth) values (@id,@DateofBirth)";
    using(SqlCommand cmd=new SqlCommand(sql,conn))
     {
        cmd.Parameters.Add("@id",SqlDbType.Int).Value=10;
        cmd.Parameters.Add("@DateofBirth",SqlDbType.DateTime).Value=dateTimePicker.Value;

        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
     }

Comment: Its work fine but during insertion of this commnd **cmd.Parameters.Add("@_name", SqlDbType.VarChar).Value = NameBox.Text;** it's prompts invalid object... how to insert it
Comment: Specify the size :  cmd.Parameters.Add("@_name", SqlDbType.VarChar,40).Value = NameBox.Text;
Comment: I got one more error now **cmd.Parameters.Add("@AccountId",SqlDbType.Int).Value = AccountInformation.AccountId;** where AccountInformation.AcountId contain integer value. but the error is **Conversion failed when converting the varchar value '@AccountId' to data type int.**
Comment: @buddy - Double check the field type of AccountID in database. As per error description - the field AccountID and AccountInformation.AcountId must be int type.
Answer: Personally I'd get into the habit of using parameters for all of your SQL queries. That way you avoid SQL injection attack vector and you can also specify the parameter type as datetime. See this answer for example.


How to deal with duplicates in database?

Question: In a program, should we use try catch to check insertion of duplicate values into tables, or should we check if the value is already present in the table and avoid insertion?
Comment: In the real world you often have to pre-validate things like this before your app hits the DB.  For example if you have a web UI you might have to do simple form validation.
Comment: Exceptions have a performance penalty. It is generally more efficient to try and avoid exceptions. You won't incur any cost in declaring the try catch block, only when the exception occurs. If your program is doing a significant number of inserts, performance may be an issue if using exception catch.
Answer: This is easy enough to enforce with a UNIQUE constraint on the database side so that's my recommendation. I try to put as much of the data integrity into the database so that I can avoid having bad data (although sometimes unavoidable).
If this is how you already have it you might as well just catch the mysql exception for duplicate value insertion on such a table as doing the check then the insertion is more costly then having the database do one simple lookup (and possibly an insert).
Answer: Depends upon whether you are inserting one, or a million, as well as whether the duplicate is the primary key.
If its the primary key, read: http://database-programmer.blogspot.com/2009/06/approaches-to-upsert.html

An UPSERT or ON DUPLICATE KEY... The idea behind an UPSERT is simple.
  The client issues an INSERT command. If a row already exists with the
  given primary key, then instead of throwing a key violation error, it
  takes the non-key values and updates the row.
This is one of those strange (and very unusual) cases where MySQL
  actually supports something you will not find in all of the other more
  mature databases. So if you are using MySQL, you do not need to do
  anything special to make an UPSERT. You just add the term "ON
  DUPLICATE KEY UPDATE" to the INSERT statement:

If it's not the primary key, and you are inserting just one row, then you can still make sure this doesn't cause a failure.
For your actual question, I don't really like the idea of using try/catch for program flow, but really, you have to evaluate readability and user experience (in this case performance), and pick what you think is the best of mix of the two.
Answer: You can add a UNIQUE constraint to your table.. Something like
CREATE TABLE IF NOT EXISTS login
(
    loginid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    loginname CHAR(20) NOT NULL,
    UNIQUE (loginname)
);

This will ensure no two login names are the same.
Answer: you can Create a Unique Composite Key
ALTER TABLE `TableName` ADD UNIQUE KEY (KeyOne, KeyTwo, ...);

Answer: you just need to create a unique key in your table so that it will not permit to add the same value again.
Answer: You should try inserting the value and catch the exception. In a busy system, if you check for the existience of a value it might get inserted between the time you check and the time you insert it.
Let the database do it's job, let the database check for the duplicate entry.
Answer: A database is a computerized representation of a set of business rules and a DBMS is used to enforce these business rules as constraints. Neither can verify a proposition in the database is true in the real world. For example, if the model in question is the employees of an enterprise and the Employees table contains two people named 'Jimmy Barnes' DBMS (nor the database) cannot know whether one is a duplicate, whether either are real people, etc. A trusted source is required to determine existence and identity. In the above example, the enterprise's personnel department is responsible for checking public records, perusing references, ensuring the person is not already on the payroll, etc then allocating an unique employee reference number that can be used as a key. This is why we look for industry-standard identifiers with a trusted source: ISBN for books, VIN for cars, ISO 4217 for currencies, ISO 3166 for countries, etc.
Answer: I think it is better to check if the value already exists and avoid the insertion. The check for duplicate values can be done in the procedure that saves the data (using exists if your database is an SQL database).
If a duplicate exists you avoid the insertion and can return a value to your app indicating so and then show a message accordingly.
For example, a piece of SQL code could be something like this:
    select @ret_val = 0
   If exists (select * from employee where last_name = @param_ln and first_name = @param_fn)
       select @ret_val = -1
    Else
       -- your insert statement here

   Select @ret_val

Your condition for duplicate values will depend on what you define as a duplicate record. In your application you would use the return value to know if the data was a duplicate. Good luck!


when adding contacts to sim card, they are only displayed after rebooting the device

Question: I am trying to add contacts to SIM Card, they seem to be added to the SIM Card but they're only visible after rebooting the device (even to the native People app)..
Here is the code I'm using:
<code>final Uri uri = Uri.parse("content://icc/adn");
ContentValues mContentValue = new ContentValues();
mContentValue.put("tag", contactName);
mContentValue.put("number", contactNumber);
getContentResolver().insert(uri, mContentValue);
</code>
is it a problem with sync'ing the contacts db after creating the contacts? if so, is there a way, may be, to force android to sync the contacts' database with the SIM Card?
Comment: Any news after 8 years?
Answer: Android contacts database synchronizes SIM Cards contacts on boot.
Any contacts added to the SIM card will be visible via the ContactsContract providers after reboot.


Stratonovich SDE and main hint for Ito's lemma

Question: I've stuck on a SDE problem. Namely, I've got to solve equation
$$
\text{d}X_t = e^{-X_t}\circ\text{d}B_t.
$$
So in order to apply Ito's lemma, I transformed this SDE into form
$$
\text{d}X_t = -\frac{1}{2}e^{-2X_t}\text{d}t +  e^{-X_t}\text{d}B_t.
$$
I don't have any clue how to pick the proper function to apply Ito's lemma on. Is there any some sort of scheme of picking such functions on various SDEs? Moreover, I would love to get some hints about the literature with some of SDEs examples, solving techniques and applications.
Answer: For $Y_{t}=e^{2X_{t}}$ we get
$$dY_{t}=Y_{t}dB_{t}$$
and so as mentioned Solution to General Linear SDE, we get
$$Y_{t}=Y_0\exp\left( \int_0^t\left(- \frac{1}{2}s^{2} \right) \mathrm{d}s + \int_0^t s\mathrm{d}B_s\right).$$
I picked a function that would lead to cancelations i.e. $e^{2X_{t}}e^{-2X_{t}}=1$.
Comment: Thanks!, also, have you got any literature to recommend?
Comment: https://math.stackexchange.com/questions/4270608/literature-for-sde


Why is memcpy() a way to add elements to a `std::map`?

Question: I've been trying to make a container for shared access between threads. And I think what I'm looking for looks something like this:
 std::map<int, std::array<char, 256>>msg_buffers; //make atomic

A map of (atomic) array<char,256> that threads will use to relay information. The thing is though, I found I can just memcopy values into the arrays referenced by the map, and they will appear as if I added the elements normally. I have a feeling this will lead to problems later on however, and I'm curious why it doesn't cause an error, or why it works at all.
This is what it looks like:
#include <array>
#include <map>

std::map<int, std::array<char, 256>>charmap; //a msg queue

char charbuf[256]; //incoming msg buffer
for (int x = 0; x < 256; x++)charbuf[x] = '0'; //make arbitrary msg

//memcopy arbitrary msg **directly** to array at (non existing) map[4]
memcpy(charmap[4].data(), charbuf, sizeof(char) * 256);

//which will then magically exist
std::cout << "Used slots in charmap are: ";
if (!charmap.empty())
    for (auto x : charmap)std::cout << x.first << " | "; //cout existing elements

And elements added with memcpy() will appear as normal, even if I did not create the element specifically. Is this something the compiler does without me knowing? I cant see how this is a way to add elements to a map, and I feel it should be giving a warning of some kind.
I used Visual Studio 2017 to compile this.
Comment: [`T& operator[]( const Key& key ); - Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist.`](http://en.cppreference.com/w/cpp/container/map/operator_at)
Comment: putting in other terms, `memcopy` is not part of the picture here: it's just that calling `charmap[4]` forces (if neded) the creation of the corresponding value.
Then you can work on the value as you need.
Comment: @tkausl that is the answer, thank you
Comment: @GianPaolo: Moreover, if `memcpy` were *creating* anything, calling `data()` on `charmap[4]` wouldn't work.
Answer: charmap[4] returns a reference to the value with the key 4 (it automatically creates the element if it does not exist yet).  This value is of type std::array<char, 256>, and can be manipulated normally.  The memcpy just copies the content into this buffer, and there is no magic with memcpy here.  In particular, it does not create new elements.
Comment: Your answer is missing something crucial concerning operator[]. If the key-value pair for key '4' does not exist then operator[] _creates_ a new map entry. Thus whether the key did or did not exist before the call to operator[] it will _always_  return a valid value reference. Therefore `memcpy` works without triggering a memory exception (segfault/access violation).
Comment: @Nathilion clarified


Finding data clusters in single variable data set

Question: I'm working with a data set and I am relatively un-versed in statistics / statistical terminology (my background is computer science) though I'm pretty techie and might know a bit more than some.
I'm working with a data set where I have a number of integer values (ranging from 1-100) and am counting the number of times each value occurs.  These values tend to cluster over the total scale and have an average error of about .75 (rounding, basically) so they tend to fall into two consecutive (or sometimes three) buckets rather than a single one.
Here's an example of the data:
6 occurred 159 times in set - 33.9019 percent
5 occurred 133 times in set - 28.3582 percent
25 occurred 72 times in set - 15.3518 percent
24 occurred 69 times in set - 14.7122 percent
78 occurred 13 times in set - 2.77185 percent
76 occurred 13 times in set - 2.77185 percent
95 occurred 5 times in set - 1.0661 percent
97 occurred 4 times in set - 0.852879 percent

For example, in the set above both 5 / 6 are basically the same number (bucket) for my use and are very important due to the fact that they make up approx. 60% of the values.  Similarly 24/25 are important with 30% overall.  If there were a 23 or 26 it would also mix into that 30% bucket.
Values with less than 2-3% registration are basically noise so while the 76 / 78 are related (and probably useful) they're likely to be read as noise and thrown out which is ok but not ideal.
What I'm interested in is identifying the clusters over the overall range most efficiently and which ones contain the greatest number of samples.
Right now I'm using a brute force method of sorting by "value" and then adding buckets together which happen to be consecutive but I'm convinced there's probably some statistical method that will serve to "find and identify clusters"
Any leads / recommendations greatly appreciated!
Answer: Proof by example doesn't work, nor does statistical analysis method by example. You will have to come up with a precise formalization of what you need. On one-dimensional integer counts that will then likely yield an algorithm already.
I assume you want:

Buckets with less than min are not clustered.
Adjacent buckets with both at least min count go to the same bucket.

This leas to a trivial algorithm that just iterates over the array once, looking at bucket[i] and bucket[i-1].
Comment: Well, I've already done it all algorithmically... but it's very specific to my data set.  It seemed to me that there must be a standardized statistical function/approach for identifying clustering in data?  Seems like a signal-processing type problem?

Again, I'm not a statistician so am trying to avoid recreating things which have already been done/established.
Comment: Finding adjacent non-zero integer values in an array is trivial. That is why there is no named algorithm for this. Clustering is multivariate, complex statistics.


How to migrate keycloak to mysql database and fix timeout after 300 exception

Question: I am trying to setup mysql to my keycloak instance and couldn't get that working due to the following exception:

Timeout after [300] seconds waiting for service container stability. Operation will roll back. Step that first updated the service container was 'add' at address '[
          ("core-service" => "management"),
          ("management-interface" => "http-interface")
      ]'
      14:34:42,546 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0190: Step handler org.jboss.as.server.DeployerChainAddHandler$FinalRuntimeStepHandler@65d34517 for operation add-deployer-chains at address [] failed handling operation rollback -- java.util.concurrent.TimeoutException: java.util.concurrent.TimeoutException
              at org.jboss.as.controller.OperationContextImpl.waitForRemovals(OperationContextImpl.java:522)
              at org.jboss.as.controller.AbstractOperationContext$Step.handleResult(AbstractOperationContext.java:1518)
              at org.jboss.as.controller.AbstractOperationContext$Step.finalizeInternal(AbstractOperationContext.java:1472)
              at org.jboss.as.controller.AbstractOperationContext$Step.finalizeStep(AbstractOperationContext.java:1445)
              at org.jboss.as.controller.AbstractOperationContext$Step.access$400(AbstractOperationContext.java:1319)
              at org.jboss.as.controller.AbstractOperationContext.executeResultHandlerPhase(AbstractOperationContext.java:876)
              at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:726)
              at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
              at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1412)
              at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:521)
              at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:472)
              at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:434)
              at org.jboss.as.server.ServerService.boot(ServerService.java:435)
              at org.jboss.as.server.ServerService.boot(ServerService.java:394)
              at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:374)
              at java.lang.Thread.run(Thread.java:748)

14:34:42,549 ERROR [org.jboss.as.controller.client] (Controller Boot Thread) WFLYCTL0190: Step handler org.jboss.as.server.DeployerChainAddHandler$FinalRuntimeStepHandler@65d34517 for operation add-deployer-chains at address [] failed handling operation rollback -- java.util.concurrent.TimeoutException.

https://developer.jboss.org/thread/272010 in this question they also had a similar exception and got it solved after changing timeout from 300 to 600.
but where can i change this setting.
BTW i changed the transaction timeout as below but still facing the issue.
<coordinator-environment default-timeout="7200" />

Comment: Increasing that timeout is likely to lead to other problems.  Please provide the SQL involved in the query.
Answer: As most of the people suggested, adding this parameter should do the fix for you.
-Djboss.as.management.blocking.timeout=3600

Answer: I use ubuntu 20.04 LTS on both my desktop and laptop. I noticed that mysql running on the docker container on the laptop while everything was fine on the desktop is running extremely slow, see MySQL bug#46959. If you're having a problem like mine, this solution might work.


quadratic equation problem.

Question: I have been fumbling for months now to acquire the solution.
My previous question was unclear, sorry for that.
$$\large 2^{x/2}+3^{x/2}=13^{x/4}$$
Please try to solve it.
Thanks in advance!!!
Comment: Hint: substitute $t$ for $\frac{x}{4}$ in the answer below.
Comment: The answer is 4.
Comment: Can you please write what have tried?
Comment: can you please show the process @DiegoMath
Comment: I am not able to find the value of x in the above equation @Nilknarf
Comment: your hint is nice!!!
Comment: I am not able to think from where I should start from but I tried expressing 13 as (3*3+2*2 )  @DiegoMath
Comment: cant understand though!!please help@Theta
Comment: @DibyaranjanMishra It is advisable to get rid of square roots, therefore make use of Dr. Sonnhard Graubner's answer below, substitute $t$ for $\frac{x}{4}$ and see what you get.
Comment: @MANMAID yes I know
Comment: @DibyaranjanMishra take $\sin t=4/\sqrt{13}$.
Comment: @MANMAID this idea does not work
Comment: The title is misleading. This isn't a quadratic equation.
Answer: HINT: write your equation in the form
$$2^{x/2}+3^{x/2}=13^{x/4}$$
and $$4^t+9^t=13^t$$ from the hint above!
Comment: I substituted x/2 as t then what should I do??
Comment: sere this in my post!
Comment: after that... I may be sounding foolish but I am in std 9 and this topic is being done for first time.so sorry for in convenience
Comment: it doesn't matter but we all here to help you!
Comment: ok so how could i solve  the equation cause its not in the standard form
Answer: Hint:  by inspection $x=4$ is a solution, then show that $\displaystyle\left(\frac{2}{\sqrt{13}}\right)^{x/2}+\left(\frac{3}{\sqrt{13}}\right)^{x/2}$
 is strictly decreasing, so $x=4$ is the only solution.
Answer: Our question:

To find $t$, such that $4^t+9^t=13^t$

$(\frac{4}{13})^t+(\frac{9}{13})^t=1$. Note that $t=1$ is trivial solution.
$\frac{4}{13},\frac{9}{13}<1$. Then, if $t>1$, $(\frac{4}{13})^t<\frac{4}{13}$. Similarly $(\frac{9}{13})^t<\frac{9}{13}$. So $(\frac{4}{13})^t+(\frac{9}{13})^t<(\frac{4}{13})+(\frac{9}{13})=1$.(Why?)
if $0<t<1$, $(\frac{4}{13})^t>\frac{4}{13}$. Similarly $(\frac{9}{13})^t>\frac{9}{13}$. So $(\frac{4}{13})^t+(\frac{9}{13})^t>(\frac{4}{13})+(\frac{9}{13})=1$.(Why?)
Hence $t=1$ is only solution.
Note: If you do not understand "Why" part, comment please. I will edit the post.

quadratic equation problem.


How to configure Broadcom 5709 NIC as iSCSI Hardware Initiator

Question: I'm having some trouble to setup an iSCSI Hardware Initiator within ESX4. The host-machine has a "Broadcom NetXtreme II BCM5709 1000Base-SX" NIC which supports TOE and can be used as an iSCSI HBA. The question is... what steps are necessary so that the NIC shows up in the list of storage adapters?
The SAN-iSCSI Guide for ESX4 only has a few lines about this and is not a big help. The NIC itself has a boot-menu which includes some iSCSI configuration. At that place I configured the ip-address for our IP-SAN but no change within ESX.
Does anybody have a clue about this? It is really starting to get frustrating for me.. and I don't want to use Vmware's software iSCSI initiator.
Thanks in advance,
Lemmy
Comment: Just a note: Every modern network chip supports ToE, and can be used fine for iSCSI in ESX.
Comment: Did you get the Broadcom NetXtreme II 5709 to works? Did you used the iSCSI Offload Key for LOM NICs? Phil
Answer: Historically, ESX has very limited support for hardware-based iSCSI HBA's. Their own iSCSI software is however 100% supported.
The only hardware iSCSI HBA's that ESX 4.0 U1 supports are listed here
Answer: I can't find any documentation that indicates that iSCSI Offload functionality is supported by ESX for hybrid devices like the Broadcom 5709 which I've always understood is not a HBA (at least according to Dell's tech folks).
ESX 4 does support IPv4 TCP Offload, specifically TSO (TCP Segmentation Offload) and LRO (Large Receive Offload), on all supported NIC's that support it AFAIK and it is enabled by default. You can check that it is enabled by looking at the MSS result from esxcfg-vmknic -l to see if the NICs used by the iSCSI VMKernel ports have TSO enabled. IPv6 offload is currently only suported for (some) Qlogic iSCSI HBA's but since it is supported within Guests using the VMXNET 3 Network adapter I'd expect to see support at the host level NICs soon.
The ESX 4 Software initiator is substantially better than previous versions, it has substantially lower CPU utilization, better multi-threading, multi-pathing and Jumbo frame support so the advantages of using HBA's for iSCSI are much less significant than they were with earlier ESX versions.
Answer: According to VMware (as of ESXi 5.1), a NIC using the Broadcom 5709 chipset is a "dependant hardware iSCSI initiator". It is not a full hardware iSCSI HBA initiator like a QLogic 4062C, but does support and contain much useful hardware that makes it better than just using a regular NIC card. It has an iSCSI initiator and an TCP/IP offload engine, but still requires configuration as a NIC and as an iSCSI initiator.
According to VMware "A dependant hardware iSCSI initiator, or adapter, (i.e., the 5709) depends on VMware networking and on iSCSI configuration and management interfaces that are provided by VMware. This type of adapter presents a standard network management adapter and iSCSI offload function on the same port. To make this adapter functional, you must set up networking for the iSCSI traffic and bind the adapter and an appropriate VMKernel iSCSI port."
I have several of them, and they are both cheap and efficient. They make a good choice, as they have good performance, and are significantly cheaper than a full hardware iSCSI initiator like a QLogic 4062C. Don't get me wrong, the QLogic is a great HBA, but is four or five times more expensive.
Answer: You have to "bind" the vmhba and the vmnic ports. Below is from the iSCSI config guide:

Use the vSphere CLI command to determine the name of the physical NIC, with which the iSCSI adapter is associated.
esxcli swiscsi vmnic list -d vmhba# (vmhba# is the name of the iSCSI adapter)
In the output, find the vmnic name: vmnic# line.
---You can also see the vmhba#'s if you view the storage adapter section in vSphere---
vmnic# is the name of the network adapter that corresponds to the iSCSI adapter.

What to do next
After you determined the name of the NIC, create an iSCSI port on a vSwitch connected to the NIC. You then bind this port to the dependent hardware iSCSI adapter, so that your host can direct the iSCSI traffic through the NIC.
I hope this helps.
Answer: Well, Helvick's answer is right. Until today, Esx(i) does not support TOE but it does support TSO. Also. Broadcom 5709 NIC has compatibility issue with Esxi 4.1 and 5.0 (NOT Sure any other version). The iSCSI connection has problem when using it as HW iSCSI intitiator on our Dell R710 even updated to lastest BIOS, firmware, and Driver. It can be only used as software iSCSI initiator. So anyone trying to get Hosts machine for vitualiztion, BE AWARE of the Broadcom NIC. As my friend told "Intel NIC is usually the preference".
BTW, VMWare states that "You cannot use Jumbo Frames on a Broadcom card that is configured as a hardware initiator performing iSCSI offload functions. You can either use Jumbo Frames or iSCSI Offload and you cannot use both together with the Broadcom adapters"
so, JF or HBA, either one.
See: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1007654
Answer: What I suspect you have is a regular NIC that supports iSCSI boot - I'm used to seeing these on IBM's servers.
If so, it has iSCSI BIOS/UEFI support so you can boot via iSCSI, the card provides enough functionality to get your OS loaded. Once you get that far, it's the OS's responsibility to do iSCSI via software.
So if this is your case, you need to use ESX's iSCSI software initiator.


Spring-Boot Mongo Db find all on query

Question: I am using maven project with spring-data-mongodb. I created a model class my model class is
@Id
private String _id;

private String message;

private String possibleAnswer;

private boolean resolved;

private String percenteageMatch;
//Getters and Setters

Then i Created a an iterface with
public interface ContextRepository extends MongoRepository<ContextUnknown, String>{}

Now in my controller i want to find all the contextUnkown documents which are not resolved.
I know the query in mongodb is db.getCollection('ContextUnknown').find({"resolved": true}).
I am unable to write it in to spring boot i tried adding Creria
Query query = new Query();
query.addCriteria(Criteria.where("resolved").is(false));
return contextRepository.findAll(query)

This is not working as findall doesn't take query as parameter, i tried the same thing with BasicQuery But still the same issue.
I want to get all the elements which are not resolved Is there any thing i should change so i can get all the elements based on query parameters.
Thanks in advance
Any help is deeply appreciated
Answer: If you want to use Query, you have to use it with MongoTemplate. But because your query is simple, you can(spring-data can) easily build it with spring-data. Add one of these methods in your repository interface;
List<ContextUnknown> findByResolvedIsFalse();

List<ContextUnknown> findByResolved(boolean resolved);

Check this link to learn more about query creation using spring repositories. If you could not build query via spring repositories or you need some aggreation etc, You can combine MongoTemplate and spring repository in one interface. You can check this question's answer to learn how to do it.
Answer: In the class you are using below code
Query query = new Query();
query.addCriteria(Criteria.where("resolved").is(false));
return contextRepository.findAll(query)

You need MongoTemplate to execute the query.
Do like this
@Autowired
private MongoTemplate mongoTemplate;

List<ContextUnknown> result = mongoTemplate.find(query, ContextUnknown.class);

Spring-Boot Mongo Db find all on query


Why this MySQL Query Successfully Executes?

Question: I am playing with Multilldae's XSS exercise and in one of the exercise(OWASP 2013->A3->Reflected->Pen Test Tool Lookup) my crafted input lead to the following query. The where clause is in a very strange form. And tool_id is an int field.
SELECT tool_id, tool_name, phase_to_use, tool_type, comment FROM pen_test_tools
WHERE tool_id = '2\", \"good\":\"haha';

Surprising to me, this query successfully executes and returns the correct result. Could you please tell me why? In my view, the where clause is completely nonsense and MySQL should report an error.
Thanks!
Comment: The `where` clause has a column equal to a constant string.  What is strange about that?
Comment: @GordonLinoff The correct where clause should be WHERE tool_id = 2, not WHERE tool_id = CONSTANT_STRING. But the strange thing is that the later also returns the correct result.
Answer: The reason is because tool_id is an integer, so the comparison is done numerically.
MySQL will convert a string to a number in a numeric context.  When it does so, it does
"silent" conversion, so errors are not reported.  It converts a string based on the leading numbers, so this string becomes 2.  If there are no leading digits (or minus signs or plus signs after leading spaces), then the value is 0.
Comment: So MySQL will abandon the rest of the string after character 2? Thanks.
Comment: Yes. When I test WHERE tool_id = '2aaaa', it also returns the correct answer. So MySQL indeed drop all characters after 2.
Comment: @ZillGate . . . MySQL will ignore characters after the numbers in a numeric context.


Global section morphism is surjective?

Question: Let $X$ be a scheme and $f:P_X^n\to X$ denotes the projective $n-$space. $f^{\#}:O_X\to f_*O_{P_X^n}$. Is $O_X(X)\to O_{P_X^n}(P_X^n)$ surjective?
Comment: Note that $\mathbb{P}^n_X=\mathbb{P}^n_{\mathbb{Z}}\times_{\operatorname{Spec}(\mathbb{Z})} X$.
Answer: It's better than surjective, it's an isomorphism. This problem is local on $X$: we have a map of sheaves and we want to verify it's an isomorphism. It suffices to check on affine opens.
On any affine open $\operatorname{Spec} R\subset X$, we can base change our map along the natural open immersion $\operatorname{Spec} R \to X$ so that we're in the situation of $f: \Bbb P^n_R\to \operatorname{Spec} R$. As $f_*\mathcal{O}_{\Bbb P^n_R}$ is a sheaf on the affine scheme $\operatorname{Spec} R$, it suffices to compute the global sections. But these are just $R$ (cf here for example), and the map is the identity, so we're finished.

Global section morphism is surjective?


Moment JS last day of month issue

Question: I am using momentJS in a project and I have a function that takes a month and year and returns the last day of the month using those parameters.
Everything is working fine, Jan - November, and as soon as I use December, it is returning January.
Any ideas how I can tweak this to work? I am passing the true month value (5 = May) and then subtracting a month within the function to make it 0 based for moment to function correctly.
Fiddle: https://jsfiddle.net/bhhcp4cb/
// Given a year and month, return the last day of that month
function getMonthDateRange(year, month) {

    // month in moment is 0 based, so 9 is actually october, subtract 1 to compensate
    // array is 'year', 'month', 'day', etc
    var startDate = moment([year, month]).add(-1,"month");

    // Clone the value before .endOf()
    var endDate = moment(startDate).endOf('month');

    // make sure to call toDate() for plain JavaScript date type
    return { start: startDate, end: endDate };
}

// Should be December 2016
console.log(moment(getMonthDateRange(2016, 12).end).toDate())

// Works fine with November
console.log(moment(getMonthDateRange(2016, 11).end).toDate())

Answer: Instead of:
var startDate = moment([year, month]).add(-1,"month");

Do this:
var startDate = moment([year, month-1]);

Basically, you don't want to start at the wrong point and then move by a month, you simply want to start at the correct point.
Comment: totally makes sense, didn't catch that one - thank you!
Answer: You can parse the date with a format, then moment will parse the date correctly without the need of subtracting a month. I think it's more readable in the end
var startDate = moment(year + "" + month, "YYYYMM");
var endDate = startDate.endOf('month');

// Given a year and month, return the last day of that month
function getMonthDateRange(year, month) {
    var startDate = moment(year + "" + month, "YYYYMM");
    var endDate = startDate.endOf('month');

    // make sure to call toDate() for plain JavaScript date type
    return { start: startDate, end: endDate };
}

// Should be December 2016
console.log(moment(getMonthDateRange(2016, 12).end).toDate())

// Works fine with November
console.log(moment(getMonthDateRange(2016, 11).end).toDate())

Moment JS last day of month issue


What is the max addressable memory space in a 32-bit C++ program?

Question: In debug mode I saw that the pointers have addresses like 0x01210040,
but as I realized, 0x means hexadecimal right? And there're 8 hex digits, i.e. in total there're are 128 bits that are addressed?? So does that mean that for 32-bit system the first two digits are always 0, and for a 64-bit system the first digit is 0?
Also, may I ask that, for a 32-bit program, would I be able to allocate as much as 3GB of memory as long as I remain in the heap and use only malloc()? Or is there some limitations the Windows system poses on a single thread? (the IDE I'm using is VS2012)
Since actually I was running a 32-bit program in a 64-bit system, but the program crashed with a memory leak when it only allocated about 1.5GB of memory...and I can't seem to figure out why.
(Oooops...sorry guys I think I made a simple mistake with the first question...indeed one hex digit is 4 bits, and 8 makes 32bits. However here is another question...how is address represented in a 64-bit program?)
Comment: Each hex digit is 4 bits, so 8 hex digits == 32 bits...
Comment: 2^32 bytes = 4294967296B = 4GB
Comment: arrrgh!!That's right...why did I just have the crazy idea that each hex digit is two bytes...
Comment: What exactly are you asking? In a 32-bit program an address is a 32-bit value. In a 64-bit program an address is a 64-bit value (although [only the low 48 bits are used](http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details)). The hexadecimal representation is just used to display an address to humans, like all numbers they are represented in binary (that's what _bit_ means)
Comment: In a linear address space, the possible address space is 4GB.  One note is that many hardware items are memory mapped to addresses.  So your program may not be able to address the entire range.
Answer: For 32-bit Windows, the limit is actually 2GB usable per process, with virtual addresses from 0x00000000 (or simply 0x0) through 0x7FFFFFFF. The rest of the 4GB address space (0x80000000 through 0xFFFFFFFF) for use by Windows itself. Note that these have nothing to do with the actual physical memory addresses.
If your program is large address space aware, this limit is increased to 3GB on 32bit systems and 4GB for 32bit programs running on 64bit Windows.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366912(v=vs.85).aspx

And for the higher limits for large address space aware programs (IMAGE_FILE_LARGE_ADDRESS_AWARE), see here:

http://msdn.microsoft.com/en-us/library/aa366778.aspx

You might also want to take a look at the Virtual Memory article on Wikipedia to better understand how the mapping between virtual addresses and physical addresses works. The first MSDN link above also has a short explanation:

The virtual address space for a process is the set of virtual memory
  addresses that it can use. The address space for each process is
  private and cannot be accessed by other processes unless it is shared.
  A virtual address does not represent the actual physical location of
  an object in memory; instead, the system maintains a page table for
  each process, which is an internal data structure used to translate
  virtual addresses into their corresponding physical addresses. Each
  time a thread references an address, the system translates the virtual
  address to a physical address. The virtual address space for 32-bit
  Windows is 4 gigabytes (GB) in size and divided into two partitions:
  one for use by the process and the other reserved for use by the
  system. For more information about the virtual address space in 64-bit
  Windows, see Virtual Address Space in 64-bit Windows.

EDIT: As user3344003 points out, these values are not the amount of memory you can allocate using malloc or otherwise use for storing values, they just represent the size of the virtual address space.
Comment: thanks! But actually my system is 64bit, and I haven't declared the 2GB limit as described in MSDN...but the program itself is inherently 32-bit so I guess I can use 4GB most (or is it 32bit?? How would one check if a program is 64bit or not?)
Comment: Check your settings in Visual Studio, there you can change the build architecture to either 32bit or 64bit. If you are still unsure, use the `dumpbin` tool as described [here](http://superuser.com/a/358459/59125)
Answer: There are a number of limits that would restrict the size of your malloc allocation.
1) The number of bits, restricts the size of the address space. For 32-bits, that is 4B.
2) System the subdivide that for the various processor modes. These days, usually 2GB goes to the user and 2GB to the kernel.
3) The address space may be limited by the size of the page tables.
4) The total virtual memory may be limited by the size of the page file.
5) Before you start malloc'ing, there be stuff already in the virtual address space (e.g., code stack, reserved area, data). Your malloc needs to return a contiguous block of memory. Largest theoretical block it could return has to fit within unallocated areas of virtual memory.
6) Your memory management heap may restrict the size that can be allocated.
There probably other limitations that I have omitted.
-=-=-=-=-
If your program crashed after allocating 1.5GB through malloc, did you check the return value from malloc to see if it was not null?
-=-=-=-=-=
The best way to allocate huge blocks of memory is through operating system services to map pages into the virtual address space.---not using malloc.
Answer: In reference to the following article
For a 32-bit application launched in a 32-bit Windows, the total size of all the mentioned data types must not exceed 2 Gbytes.
The same 32-bit program launched in a 64-bit system can allocate about 4 Gbytes (actually about 3.5 Gbytes)
The practical data you are looking at is around 1.7 GB due to space occupied by windows.
By any chance how did you find out the memory it had allocated when it crashed.?
Comment: yes...32bit program in 64bit windows, I was checking the task manager and saw the thread take up more and more memory until it crashes at 1.5


Access the state in an action in redux

Question: Many links and tutorials advice to group the logic in action creators in order to simplify the reducer logic.
Imagine a simple (normalized) state:
const initialState = {
  parent: {
    allIds: [0],
    byId: {
      0: {
        parentProperty: `I'm the parent`,
        children: [1, 2]
      }
    }
  },
  children: {
    allIds: [1, 2],
    byId: {
      1: {
        childrenProperty: `I'm the children`
      },
      2: {
        childrenProperty: `I'm the children`
      }
    }
  }
}

I would now delete the parent. Since only the parent refers to the children, I would also delete the children too.
I imagine a action creator like this:
function deleteParents(parentId) {
  return {type: 'DELETE_PARENT', payload: {parentId}};
}

and
function deleteChild(childId) {
   return {type: 'DELETE_CHILD', payload: {childId}};
}

For now, to manage this case I do something like this (with redux-thunk)
function deleteParentAndChildren(parentId) {
  return (dispatch, getState) {
    const childrenIds = myChildrenSelector(getState(), parentId);
    const deleteChildrenActions = childrenIds.map(deleteChild);
    const deleteParentAndChildrenAction = batchActions([
      deleteParents(parentId),
      ...deleteChildrenActions
    ], 'DELETE_PARENT_AND_CHILDREN');
    dispatch(deleteParentAndChildrenAction);
  }
}

In that way, I compose little action into big one, and the reducer logic is very simple because it only consist to delete a key in an object.
Conversely, I don't like to use redux-thunk (used to async actions) just to get the state (and this is considered as anti pattern).
How do you guys manage this type of problems ?
Does a tool like redux-sage may help ?
Comment: Can you be more clear on what you are trying to achieve, please? So you would like a way to delete a parent and all corresponding children?
Comment: exactly, so sorry to be unclear. I would also keep little (and composable) actions
Comment: Have you considered reevaluating your data structure? I would consider having the parent key and the children key as arrays, with objects inside. Each object has its structure with a reference ID. A parent object could have a children array containing the ids of the related children.

I would have an async action using redux-thunk to call the removal of the parent, the final action call for a successful deletion could then trigger another async action to delete any children with the ref id related to the parent that was removed.
Answer: I opine differently here. The way I would do it is, I would delete child while deleting parent but not y dispatching child_delete action. When you create new state while deleting parent in reducer, at that time, you can access the children referred by that parent, and remove those as well from state.
Also, if you still want to dispatch actions separately, you can pass childids from component to action. From that action, you can dispatch two different actions, deleting parent and chilren ids.
-----------  EDIT -------
// The initial application state
const initialState = {
  parent: {
    allIds: [0],
    byId: {
      0: {
        parentProperty: `I'm the parent`,
        children: [1, 2]
      }
    }
  },
  children: {
    allIds: [1, 2],
    byId: {
      1: {
        childrenProperty: `I'm the children`
      },
      2: {
        childrenProperty: `I'm the children`
      }
    }
  }
}

export default function batchManagement(state = initialState, action) {
  switch (action.type) {
    case 'DELETE_PARENT':  //assuming action.deleteParents = [0]
      //Here you have access to state, so you can change parents and children as well, and create a totally new state
    case 'DELETE_CHILDREN':
      //Return a new object for state
    default:
      return state;
  }
}

Comment: Yes you are right. But to find the children Ids, I need the state. That means I need redux-thunk as a work around (even to do synchronouse action).
Comment: Hi @Epitouille, I guess you didn't get me right. When you right a reducer method, you get access to state. Please see my edited answer
Comment: Oh Yes I didn't get you right. The problem with your option is my full reducer is: `combineReducer({parent, children});` So I never access the full state of my app. I only get a slice. :)
Comment: My bad. Didn't think of that option. Let me figure out what else can be done.

Well in that case, do you have access to children ids referred by parent in component. If you have the childrenids, you can separately dispatch parent_delete and children_delete from component
Comment: For now, I use the method with redux-thunk described in the original question. May not be the best solution but it works well. The other problem comes if children have children (grand-children). I can only have the grand children ids if I resolve the children. In all case, I'll need the full state somewhere. The best solution is probably the @guillaumepotier answer and use and ORM.
Answer: The problematic you seem to have seems fairly common and if your application is a bit sophisticated I would suggest using redux-orm which is a bit hard to understand and then integrate but once set up it just abstract you all the hard relationship work between your entities.

Access the state in an action in redux


Multilateral shift operators

Question: Apparently, the operators
$u(e_n) = e_{n+1}$
and
$u^\ast (e_n ) = e_{n-1}$
are called "unilateral shift oeprator".
Since they have to be called that (instead of calling them "the shift operator") I am wondering what the other types of shift operators are. I am struggling to come up with a definition for a multilateral shift operator.
What other shift operators are there?
Answer: The unitary shift operator on $l^{2}(\mathbb{Z})$ is not unilateral. This operator is the same as multiplication by $e^{i\theta}$ on $L^{2}[0,2\pi]$ with normalized inner product
$$
              (f,g) = \frac{1}{2\pi}\int_{0}^{2\pi}f(\theta)\overline{g(\theta)}\,d\theta.
$$
You can see this because every $f \in L^{2}[0,2\pi]$ can be written as the orthogonal sum
$$
                       f = \sum_{n=-\infty}^{\infty}(f,e^{in\theta})e^{in\theta}.
$$
The unilateral shift is multiplication by $z$ on the Hardy space $H^{2}(D)$ consisting of all holomorphic functions $f(z)=\sum_{n=0}^{\infty}a_n z^{n}$ in the unit disk $D$ such that
$$
                    \|f\|^{2} = \sum_{n=0}^{\infty}|a_n|^{2} < \infty.
$$
Another common type of shift is a weighted shift where
$$
              e_{n} \mapsto \lambda_n e_{n+1}.
$$

Multilateral shift operators


Interesting formula for Euler-Mascheroni constant?

Question: Playing around with Wolfram Alpha I found a possible formula for the Euler-Mascheroni constant $\gamma$:
$$
\lim_{x \to \infty}\sum_{n=1}^{\infty} \frac{1}{n^{1+1/x}} - x = \gamma
$$
This can also be written in terms of the Riemann Zeta function like
$$
\lim_{x \to \infty}\zeta(1+\frac{1}{x}) - x = \gamma
$$
I find this remarkable, because this seems to imply that $\zeta(1)$ is "a little bit bigger than infinity"
$$
\infty + \gamma = \zeta(1)
$$
Is this really a valid formula for $\gamma$ ?
Update: Curiously I also found a similar formula for the Gamma function
$$
\lim_{x \to \infty}\Gamma(\frac{1}{x}) - x = -\gamma
$$
Combining both equations generates again an interesting formula
$$
\lim_{x \to \infty} \frac{1}{2}\left(\zeta(1+\frac{1}{x}) - \Gamma(\frac{1}{x})\right) = \gamma
$$
Answer: Your observation comes from the Laurent series expansion of the Riemann zeta function near $1$ (see here) giving, as $t \to 0^+$,
$$
\zeta(1+t) = \frac{1}{t} + \gamma + o(1)
$$ then just set $t=\dfrac1x$ with $x \to \infty$.
Answer: $\lim_{x \to \infty}\sum_{n=1}^{\infty} \frac{1}{n^{1+1/x}} - x = \gamma
$
Let's look at the partial sums.
$\begin{array}\\
\sum_{n=1}^{m} \frac{1}{n^{1+1/x}}
&=\sum_{n=1}^{m} \frac{1}{n}\frac{1}{n^{1/x}}\\
&=\sum_{n=1}^{m} \frac{1}{n}e^{-\ln n/x}\\
&\approx \sum_{n=1}^{m} \frac{1}{n}(1-\ln n/x)
\qquad\text{for large } x\\
&= \sum_{n=1}^{m} \frac{1}{n}-\frac1{x}\sum_{n=1}^{m}\frac{\ln n}{n}\\
&= \ln(m)+\gamma+o(1)-\frac1{x}\sum_{n=1}^{m}\frac{\ln n}{n}\\
&= \ln(m)+\gamma+o(1)-\frac1{x}(\frac{\ln^2(m)}{2}+O(1))
\qquad(*)\\
&= \ln(m)+\gamma+o(1)-\frac{\ln^2(m)}{2x}+O(\frac1{x})\\
&= \ln(m)+\gamma+o(1)-\frac{\ln^2(m)}{2x}+O(\frac1{x})\\
\end{array}
$
Therefore
$\sum_{n=1}^{m} \frac{1}{n^{1+1/x}}
-\ln(m)-\gamma
=o(1)-\frac{\ln^2(m)}{2x}+O(\frac1{x})
$
(*) http://www.maths.lancs.ac.uk/~jameson/emnotes.pdf,
p. 14


Projection on C*-Algebra

Question: I am trying to show that if A is an arbitrary C*-algebra, $p$ is a projection if and only if $p^{*}p = p$. Now since the C*-algebra is arbitrary, we only have a norm and not necessarily an inner product, and I do not know how I can use the adjoint in this setting. Can someone give me a hint?
Comment: What's your definition of a projection in a $C^*$ setting? The one I know is $p=p^{*}=p^2$.
Comment: A C*-homomorphism with $p^2 = p$, I think.
Comment: The word projection is usually used for _elements_ of a $C^*$ algebra, not for morphisms of it. What exactly are you looking at?
Comment: You are right, it seems to refer to elements of an arbitrary C*-algebra
Comment: Regarding the second sentence of the question - every C$^*$-algebra has a faithful representation on a Hilbert space, so if you proved $p$ is a projection iff $p^*p = p$ for operators on a Hilbert space, this would prove it for elements of an arbitrary C$^*$-algebra. Often it is easier to give direct algebraic proofs, though, as Aweygan did.
Answer: The identity $p^*p=p$ implies
$$p^*=(p^*p)^*=p^*p=p,$$
and thus
$$p=p^*p=p^2$$

Projection on C*-Algebra


Publish Visual basic error

Question: Boa noite amigos. Estou com uma dificuldade ao compilar meu projeto. Ele apresenta esse erro. O que pode ser?
Comment: Já tentou iniciar o Visual Studio como Administrador? Você tem os privilégios para acessar a pasta C:\ ?
Answer: Seu erro:

Failed to copy file 'C:\Users\Rodrigo\Desktop\pacote\pacoteprograma\bin\Debug\app.publish\setup.exe' to 'C:/setup.exe'. Unable to add 'setup.exe' to Web site. Unable to add file 'setup.exe'. Acesso negado.

Ele está tentando colocar o setup.exe na pasta raiz (C:\). O windows não permite esse tipo de coisa sem permissão de administrador (e mesmo se permitisse, seria uma péssima ideia, não é a toa que ele não permite). Por causa disso que o resultado é o "Acesso negado".
Você tem que configurar no campo "Publishing Folder location (ftp server or file path):" que está aí na sua tela para uma pasta que seja adequada para colocar os seus arquivos compilados.
Comment: Show de bola amigao sem palavras (y)

Publish Visual basic error