Can I stop Drupal from trying to get file size from URLs when saving files?

Question: Saving a Drupal file with an S3 URL results in a watchdog message like this:

PHP Warning:  filesize(): stat failed for https://s3.amazonaws.com/[…]

This happens because Drupal 7's file_save() runs filesize() unconditionally on every file's URL before saving, and it seems to fail for all URLs even when it is publicly available. I've verified that the file is available using curl and I've subsequently verified that filesize() still fails, so this is not a timing issue (there are no special characters in the URL):
# curl --head https://s3.amazonaws.com/[…]
HTTP/1.1 200 OK
[…]
Content-Length: 9008
Server: AmazonS3
# php -a <<< "echo filesize('https://s3.amazonaws.com/[…]');"
[…]
PHP Warning:  filesize(): stat failed for https://s3.amazonaws.com/[…] in php shell code on line 1

Is there a way of avoiding such warnings when running file_save() not involving silencing errors globally?
Comment: Requesting the content length via `filesize` on an S3 stream is perfectly valid: http://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-s3-stream-wrapper.html. It's not failing because of Drupal's choice of method to get the info, it'll be a server or S3 issue most likely. The `stat` failure indicates the file whose size is being measured doesn't actually exist on S3 at the time of the request, so that might be where to start the debugging. You can't change the use of `filesize` without patching the core function(s) to the best of my knowledge
Comment: To address your edit: _filesize(): stat failed_ literally means that the Amazon API said "no, this file doesn't exist" or "no, you don't have access". It's quite unlikely this is any problem with Drupal, and very likely it's a problem with, say, ACLs, in your S3 config. Trying to address this at the Drupal side would mean either patching the core file functions, patching the S3 module's stream wrapper, or patching core's base stream wrapper class. I can't see any other way, and it wouldn't actually address the underlying issue anyway, it would just mask it
Comment: Why -1? Whether it's a problem with Drupal or not, isn't the problem properly explained and the use case sane?
Comment: I haven't voted, but if it's not a Drupal problem maybe they saw it as "not useful" to a Drupal-specific Q+A site? Difficult to say
Comment: I'd call this a bug - it calls something which isn't needed (the file works fine with a size of 0 in the relevant Drupal table). If the size is needed for other cases, maybe it should be optional, but if it's there "just in case" it should be removed.
Comment: It is required though - it's used to serve the correct content-length header when a private file is downloaded, for example. Also for file size validation, per-user used-space validation. And so on. You can't blame Drupal because your S3 bucket isn't configured correctly - that's the problem you should be trying to fix, not trying to hack around a perfectly reasonable use of a built-in PHP function!
Comment: I don't know why I can't convince you that the bucket is configured just fine - the code is there to prove that `curl` can get the size just fine. I also have over 10000 users with millions of images served through tested code (to the point where we're using Fake S3 for integration tests) who have not complained about any accessibility problems.
Answer: Via another question, a workaround is to write a custom error handler which ignores only this specific message:
function filesize_for_url_ignoring_error_handler($severity, $message, $file, $line, $context) {
    global $originalErrorHandler;
    if (strpos($message, 'filesize(): stat failed for https://') !== 0) {
        $originalErrorHandler($severity, $message, $file, $line, $context);
    }
}

class […] {
    public function […] {
        $originalErrorHandler = set_error_handler('filesize_for_url_ignoring_error_handler');
        $file = file_save($file);
        restore_error_handler();
    }
}

Not ideal, but it works.


Erro ao enviar formulário de email

Question: Estou com o seguinte problema fiz um formulário de envio de email porem ele da um erro segue a imagem do erro e o código obs: estou usando laravel
O HTML:

Preencha o formulário para

Entrar em Contato

                @if (count($errors) > 0)

                            @foreach ($errors->all() as $error)

{{ $error }}

                            @endforeach

                @endif

                @if (session('message'))

                        {!! session('message')  !!}

                @endif
                {!! Form::open(array('action' => 'FormController@postContato', 'role' => 'form', 'class'=>'form-inline')) !!}
                {!! Form::text('nome', null, array('placeholder'=>'Digite nome', 'class'=>'form-control')) !!}
                {!! Form::text('email', null, array('placeholder'=>'Digite e-mail', 'class'=>'form-control')) !!}
                {!! Form::text('telefone', null, array('placeholder'=>'Digite seu Telefone', 'class'=>'form-control')) !!}
                {!! Form::text('assunto', null, array('placeholder'=>'Assunto', 'class'=>'form-control')) !!}
                {!! Form::textarea('mensagem', null, array('placeholder'=>'Mensagem', 'class'=>'form-control', 'rows'=>'5')) !!}
                {!! Form::submit('Enviar Mensagem', array('class' => 'btn-black btn-blue bounce-green'), array('id' => 'btn_submit')) !!}
                {!! Form::close() !!}

O corpo da mensagem:

Nome: {!! $nome !!}
Email: {!! $email !!}
Telefone: {!! $telefone !!}
Asssunto: {!! $assunto !!}
Mensagem: {!! $mensagem!!}

o Laravel:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Validator;
use Mail;
use App\Http\Requests;

class FormController extends Controller
{
    public function contato() {
        return view('contato');
    }

    public function postContato(Request $request) {
        $rules = array( 'nome' => 'required', 'email' => 'required|email', 'telefone' => 'required', 'assunto' => 'required', 'mensagem' => 'required' );
        $errors = [
            'required'    => 'O campo :attribute é obrigatório.',
            'email'    => 'Digite um email válido.',
        ];
        $validation = Validator::make($request->all(), $rules, $errors);
        $data = array();
        $data['nome'] = $request->input("nome");
        $data['email'] = $request->input("email");
        $data['telefone'] = $request->input("telefone");
        $data['assunto'] = $request->input("assunto");
        $data['mensagem'] = $request->input("mensagem");

        if($validation->passes()) {
                Mail::send('emails.contato', $data, function($message) {
                    $message->from($request->input("email"), $request->input("nome"));
                    $message->to('firstname.lastname@example.com') ->subject('TorreForte');

                });
            return redirect('contato')->with('message', 'Mensagem enviada com sucesso!');
        }
        return redirect('contato')->withErrors($validation);
    }
}

O erro:
Comment: Qual é a linha 33? pode colocar um comentário (no código) indicando ela?
Answer: Da uma pesquisada sobre funções anonimas e escopo de função do php.
O problema é que a função que voce passa como parametro na função Mail::send() o escopo é diferente, e variavel $request, que você usa la dentro, não existe.
Para funcionar precisa dizer ao php para "injetar" a variavel $request no escopo da função, isso se faz com o use.
Mail::send('emails.contato', $data, function($message) use($request) {
    seu codigo....
}

Comment: ai tem que verificar os dados de email que voce configrou la em app/config/email.php, pelo jeito ta configurado para enviar atraves de um smpt externo e nao com a funcao mail padrao do php, provavelmente algum dado de autenticacao esta errado.
Comment: opa amigo agora o erro mudou Connection could not be established with host mailtrap.io [Connection refused #111]
Comment: cara vc manja de mais vle mesmo pela ajuda te amooo

Erro ao enviar formulário de email


google workspace authentication withouth the windows pop up just with api key or client id or seceret

Question: I need to authenticate the users api for the google workspace without the popup window open and click on my gmail account is there any way to do that just with the api key or client and secret.
Comment: Edit your question to state what you are trying to do clearly. In some cases, you can use a service account with Domain Wide Delegation.
Answer: I don't think that's possible because the OAuth consent screen is a native security feature for API access to certain scopes (Specially restricted scopes). This will always happen when there is a user interaction Consent Screen.
That said, the only way to avoid that may be using a service account depending on what you are trying to do.


Como instalar cabeçalhos do phpize

Question: Quando utlizo o phpize no OSX 10.12.4, obtenho o seguinte erro:
<code>$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
</code>
Como instalar os cabeçalhos que estão faltando?
Comment: Depende muito de onde baixou e o processo que fez para baixar o phpize, me parece que você deixou de instalar o PHP primeiro, ou talvez esteja usando Mamp ou Xampp, de qualquer forma acho que isto resolve http://stackoverflow.com/q/19531262/1518921
Answer: No OSX para instalar os arquivos da pasta /usr/include é necessário instalar as ferramentas de linha de comando do Xcode, no terminal execute:
<code>$ xcode-select --install
</code>

Como instalar cabeçalhos do phpize


xtmelogit vs. glmer different results

Question: My dataset (long format) contains of data collected in 4 studies. Although the variables in the studies were identical, I want to account for the substantial heterogeneity of the populations between these studies and thus treat "study" as a random effect.
In each study, participants were randomly presented with 25 binary choices (0/1).
I want to test whether attitudes and trait self-control predict making choice 1.
Thus, my logistic regression model should account for the fact that each subject made 25 decisions and that the subjects were nested within one study.
To test this, I used R:
model <-glmer(
  depvar ~ attitude + selfcontrol + (1 | study/subject),
  data = df,
  family = binomial("logit")
)

and I tried the same with stata. After having defined the panel with xtset, I tried:
xtmelogit depvar attitude selfcontrol || study:

The coefficients are extremely different (and thus also the plots differ)! Is one of the models wrongly defined?
Even if I try to change things like laplace approximation, the results just does not even get close to similar.
Answer: Those are different models. In the case of lmer, you are estimating a 3-level model of decisions nested within subject within study. By the way this is different than the syntax you described in your other post. In that post, you treated study as a non-nested random intercept. I'm not sure why you have changed it, but that is your choice.
In comparison, the model you estimated with xtmelogit in Stata is a 2-level model that depends on which variables you mentioned when you xtset the data. If you wanted to run a comparable model with Stata, you should use melogit, specifying the random effects similarly as you did in lmer. For example, for a three-level model, the random effects structure in meologit would be || study: || subject:.
Comment: What version of Stata are you using? If a newer 14+, you should be using `melogit`, *not* `xtmelogit`. Either way, you need to define the random effects structure irrespective of what you did with `xtset`. So I would propose the following model: `melogit DV IV1 IV2 i.study || subject:` In `glmer`: `glmer(DV ~ IV1 + IV2 + as.factor(study) + (1|subject)`.
Comment: Thank you very much again for your answer!

I changed it because I thought that (1 | study/subject) would be more suitable for my data, as I try to tell the model that subjects were nested within study - but I may be totally wrong.
How would you do it?

Reg. Stata: I did xtset subject decisionnumber.

Which model would you chose given the data structure I described?
Wouldn't a 3-level model be correct (~25 decisions nested within one person, who themselves are nested within one study)?

Your help means a lot to me, thank you very much!! :-)
Comment: I would probably treat study as a fixed effect predictor rather than a random effect. You only have 3 studies, right? In Stata, that would mean adding it as `i.study` to your list of predictors. If you do that, then you can use `xtlogit` given that you only have two levels - observations within subject and you used `xtset` to define the cluster variable (subject).
Comment: I have 4 studies (Mturk with n=200, Mturk with n=600, Prolific with n=600 and student sample with n = 70) and the means/variance of self-control and attitudes as well as their effects on the behavior varies a lot between them.

Now I am confused in what whay the stata commands are different from each other:

xtmelogit depvar attitude selfcontrol || study: (with subject defined as cluster var)
and
melogit depvar attitude selfcontrol || study: || subject

in R this would be the exact same code, no?

Thank you, I promise this will be my last question :-)

xtmelogit vs. glmer different results


Can I use a ClearCase snapshot view as a DocRoot on a web server?

Question: I have been asked by my manager to come up the pros and cons of using a ClearCase snapshot view as a docRoot to a web server. Deployments to different environments in this case will be just an update to the view.
Ofcourse there are other considerations about how to control on what to update.
Hence my question to all the experts out there: has anyone done this before? what do you guys think about doing this.
Answer: Cons:
Using a VCS for deployment on a production server is usually considered a bad practice because:

you need to install and administer another component (here ClearCase) which isn't necessary to run your app
you need to manage permission access (usually, a production server has very limited access compared to dev, SIT -- System Integration Test -- or UAT -- User Acceptance Test -- servers)
ClearCase snapshot views can have various update glitches (hijacked files, config spec selection errors, ...) that you need to take into account.

Pros:
Since it is a web server, it is conceivable to use a VCS as a deployment tool considering the deployment process is fairly straight-forward (just copying some files without changing the structure).
It can be used to facilitate:

quick fixes committed back to the VCS (since your are already in a ClearCase snapshot view, you can "cleartool co -c "quick fix" aFile", change it, and "cleartool checkin" it back.
revision identification (cleartool ls will give you precisely the element selection rules used to display those files)

All in all, I really prefer keeping VCS for development environment, and uses other process for deployment.
It not only feels cleaner, it also remains compliant with a strong separation between dev and prod environments.
Comment: one good thing about Snapshot views (w.r.t ClearCase) is that it does not need to interact with ClearCase server at all. Only at the time of the deployment (which is basically a Cleartool update) the view needs to get an update from the server.
Comment: For some reason, I have always thought that using a version control system might be a bad idea. I am not sure why.
Comment: @HiteshSavla true, but you need to be careful with the files you are modifying then, because there will become hijacked and will need to be reconciled if you before the next update (or you will need to do a `cleartool update -overwrite`)
Comment: @HiteshSavla it is generally considered a bad idea to access dev referential (like a VCS like ClearCase) from a prod environment.
Comment: Makes sense. What are your thoughts on Rollback? Considering you are doing your deployment using Labels. All the rollback really will be is to change your config spec to now look at the older Release label. I still think it will be a bad idea. I just need to be convincing enough to my boss about why. I know compliance is a good point here.
Comment: @HiteshSavla if possible, for webapp I like to do a deployment in a separate directory per revision deployed. Rollback? I just change a symlink. Again, no need to mess with a config spec of a VCS, with potential errors during the update. The idea behind a rollback is: "I had something that worked. I tried to deploy something new that didn't work. Let's go back to what worked before. Pronto!".
Comment: @HiteshSavla And updating a snapshot view with ClearCase is the opposite of "pronto!". Everything is so slooow with ClearCase. Updating a symlink? Lightning fast (even though other operations might be needed to complete said rollback)


Compute; $\lim_{x\to\infty}\frac{(1-y^{x-1}\frac{x-1}{2})xy^{x-1}}{1-xy^{x-1}}$ with $0 \leq y <1$.

Question:
Prove that $$\lim_{x\to\infty}\frac{(1-y^{x-2}\frac{x-1}{2})xy^{x-1}}{1-xy^{x-1}}=1$$ where $x \in \mathbb{N}$ ($x \neq 0$) and $0 \leq y <1$.

I have managed to to multiply by $\frac{2}{2}$ to get
$$\lim_{x\to\infty}\frac{[2-y^{x-1}(x-1)]xy^{x-1}}{2-2xy^{x-1}}$$
And then, through expanding and rearranging :
$$\lim_{x\to\infty}\frac{(2-2xy^{x-1})xy^{x-1}+x^{2}y^{2x-2}+xy^{2x-2}}{2-2xy^{x-1}}$$
Which obviously results in :
$$\lim_{x\to\infty}\bigg(\frac{xy^{x-1}}{2-2xy^{x-1}}+\frac{x^{2}y^{2x-2}+xy^{2x-2}}{2-2xy^{x-1}}\bigg)$$
However I don't know how to go on from here.
Comment: Welcome to MSE !  Why downvote?
Comment: @GNUSupporter There is a big problem with downvotes in this forum the time being (have experienced it too). Don't pay attention to it, this is a perfectly asked question. Flag any post you think that gets downvoted for no reason and moderators will look into it !
Comment: if $0\leq y<1$, how does it go to infinity?
Answer: The case $y=0$ trivialy gives zero. Let $y>0$

Now since $0<y<1\implies \ln y<0$ then
$$\color{red}{\lim_{x\to\infty } (x-1)\ln y =-\infty}$$
then, we have,
$$ \lim_{x\to\infty}   \frac{x-1}{2}y^{x-1} = \lim_{x\to\infty}\frac{x-1}{2}\exp\left((x-1)\ln y\right) \\\overset{\color{blue}{u=(x-1)\ln y}}{=}\frac{1}{2\ln y}\lim_{\color{red}{u\to-\infty}}u\exp\left(u\right) =0.$$
Similarly,  $$ \lim_{x\to\infty}xy^{x-1}  =0$$
Hence,
$$\color{blue}{\lim_{x\to\infty}\frac{(1-y^{x-1}\frac{x-1}{2})xy^{x-1}}{1-xy^{x-1}}=0} $$


when use two class in xml give error unbound prefix error

Question: I want to use two class in xml
 <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
xmlns:wave="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.example.tesst.MaskableFrameLayout
android:id="@+id/frm_mask_animated"
android:layout_width="100dp"
app:porterduffxfermode="DST_IN"
app:mask="@drawable/animation_mask"
android:layout_height="100dp">

<com.john.waveview.WaveView
    android:id="@+id/wave_view"
    android:layout_width="300dp"
    android:layout_height="300dp"
    wave:above_wave_color="@android:color/white"
    wave:blow_wave_color="@android:color/white"
    wave:progress="80"
    android:layout_gravity="center"
    wave:wave_height="little"
    wave:wave_hz="normal"
    wave:wave_length="middle" />
</com.example.tesst.MaskableFrameLayout>
 </FrameLayout>

What is wrong with it? The error:Error parsing XML: unbound prefix shows up!
I do not know what is the problem
Help please
Comment: Close your MaskableFrameLayout: `` and don't forget to do that for the parent FrameLayout at the end: ``
Comment: Thanks .The problem is something else. I put the code in full
Answer: You're using the "app:" prefix, and that's not defined.
Change
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 xmlns:wave="http://schemas.android.com/apk/res-auto"

To
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 xmlns:wave="http://schemas.android.com/apk/res-auto"
 xmlns:app="http://schemas.android.com/apk/res-auto"


Definition of equivariant chain complex.

Question: What do we mean by equivariant chain complex? Is it a chain complex with some property ? I looked in many references and i did not find a definition of the expression "equivariant chain complex", I met this expression when reading about homology with local coefficients and it seems that they use it as a name for the cellular chain complex of the universal covering of a finite connected CW-complex $X$. It seems like it has a link with the action of $\pi_1(X)$ on the universal covering $\tilde X$ by Deck transformations but in what sense is this action equivariant ? thank you for your help !
Comment: Usually this means it's kosher with respect to some group acting on it.
Answer: It means the complex of chains $c$ on $\widetilde X$ which are "equivariant with respect to deck transformations", meaning that for each deck transformation $f : \widetilde X \to \widetilde X$ the formula $f_\#(c)=c$ holds.
Comment: Yes, that's what it means. The one thing you have to be careful about is that this actually only makes sense when $\pi_1(X)$ is a finite group, because the free abelian group on the $p$-cells only allows finitely many cells to have nonzero coefficients (that problem, by the way, does not arise for equivariant cohomology, which is not a free abelian group over the cells, but instead a direct product over the cells).
Comment: There is also one other thing to say. Although coefficients have not been mentioned, what makes things more interesting is that one is often (usually?) interested in "twisted coefficients" which means that the coefficients are some kind of $\pi_1(X)$-module; see [this question](https://math.stackexchange.com/questions/658673/homology-with-local-coefficients-in-a-mathbbz-pi-1x-module?rq=1).
Comment: Do you mean that the induced homomorphism on the chain level  $f_\#:C_p(\widetilde X)\longrightarrow C_p(\widetilde X)$ is the identity map ? where $C_p(\widetilde X)$ is the free abelian group on the $p-$cells of $\widetilde X$.


python3 HTTP request taking a long time

Question: I'm using the requests library to fetch a simple URL (I've put a dummy URL here, a normal URL is used in code):
import requests
response = requests.get("http://example.com/foo/bar/", headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"})

Locally it works fine, but when I put the same code on my server, this request takes forever to finish. I've enabled logging output for all of these loggers:
urllib3.util.retry
urllib3.util
urllib3
urllib3.connection
urllib3.response
urllib3.connectionpool
urllib3.poolmanager
requests

This is the only output produced by them:
2018-05-31 19:55:56,894 - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): example.com
2018-05-31 19:58:06,676 - urllib3.connectionpool - DEBUG - http://example.com:80 "GET /foo/bar/ HTTP/1.1" 200 None

The funny thing is that it always takes exactly 2 minutes and 10 seconds for the request to finish (if you disregard milliseconds). Locally it's instant.
Any clues where I should look next?
Comment: Given `wget` has the same issues, it's a safe bet this has nothing to do with Python (or programming at all), and everything to do with the server's network setup/config. Maybe ask over at Server Fault?
Comment: How big is the file being pulled? What sort of downstream bandwidth does your server guarantee, and how much is already used to service existing connections? Servers are frequently underprovisioned on downstream bandwidth, especially servers marketed to people who largely serve static content. If you run a plain `wget` from the server, is it equally slow?
Comment: A good idea! Yes, wget is equally slow, strange. It's a Linode server, totally empty and unused (except for the OS itself). The website is a fairly normal, old-fashioned one. Downloaded it's 40KB.
Comment: Yeah, I think I'll do that. Thanks!
Answer: This sounds like there is an issue with the underlying IPv6 connection. The fact that the request takes exactly 2 minutes and 10 seconds is a give-away, because that suggests the IPv6 request times out.
Verify by utilizing, e.g., wget or curl:
wget --inet6-only https://www.example.com -O - > /dev/null
# or
curl --ipv6 -v https://www.example.com

In both cases, we force the tool to connect via IPv6 to isolate the issue. If this times out, try again forcing IPv4:
wget --inet4-only https://www.example.com -O - > /dev/null
# or
curl --ipv4 -v https://www.example.com

If this works fine, you have found your problem! But how to solve it, you ask?

A brute-force solution is to disable IPv6 completely.
You may also disable IPv6 for the current session only.
You may just want to force requests to use IPv4. (In the linked answer, you have to adapt the code to always return socket.AF_INET for IPv4.)
If you want to fix this problem for SSH, here is how to force IPv4 for SSH. (In short, add AddressFamily inet to your SSH config.)
You may also want to check if the problem lies with your DNS or TCP.

Didn't solve your issue?
If that did not solve your issue, I have collected some other possible solutions here.

python3 HTTP request taking a long time


SQL Server 2005 Issue

Question: I am stuck.
I've just taken over maintenance on a SQL Server...that has not been backed up in quite a while...The log file has grown to over 1.61TB...Yes, 1.61TB.
It has swallowed all available disk space.  I've tried to backup (can't because of the log file size), I've tried detaching (can't because the logfile is full), I've tried shrinking the DB and log file (can't...get various errors.)  I'm in a really tough spot for a couple of reasons...

This is no longer a program that is 'used' but folks still access it to get data.
This has taken a 2TB drive down to 9.94MB.

Help.
EDIT:  Additionally, I can not change the recovery mode to "FULL" to do a proper backup...It just sits and spins...I'm going to give it a couple of hours and check in on it.
What a pain.
Comment: What recovery model is the database in?
Comment: I also hope/assume this is not the system disk.
Answer: Usually in these cases, it's best to switch the recovery mode of the database to Simple, then do a shrink on the log file (not the database itself). Sometimes you'll have to shrink the log a couple times to get it down.
If you can't get a good backup before doing this, be sure to get a good back immediately after.
Comment: The usual thing that can cause it to grow in Simple is a stuck open transaction. If you have a transaction that never closes, you cannot ever shrink the log. Run "DBCC OPENTRAN" to find the longest running transaction.
Comment: DB has been in Simple...can't switch to full because...you guessed it, log file is full...
Comment: It's really odd for the transaction log to grow like that in simple recovery.
Answer: Since you said the database is in simple recovery...  Try this, in chunks, during scheduled maintenance (there will be downtime).
USE master
Go
ALTER DATABASE YourDB
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;

ALTER DATABASE [YourDB] SET RECOVERY SIMPLE WITH NO_WAIT
GO

(I know, I know, you said it was simple.  But that's some weird behavior for simple recovery.)

USE [YourDB]
GO
DBCC SHRINKFILE (N'YourDB_log' , 0, TRUNCATEONLY)
GO

and
USE [YourDB]
GO
DBCC SHRINKFILE (N'YourDB_log' , 0)
GO

(Repeat as necessary.)

ALTER DATABASE YourDB
SET MULTI_USER;
GO

And then back it up.

Edit:  Okay, so that didn't work.  If you have another SQL 2005 server, you might want to try copying the mdf to the other server and using
EXEC sp_attach_single_file_db @dbname='YourDb',
@physname=N'D:\Path\YourDb.mdf'
GO

If that works, you can back up the old database files elsewhere, drop the old database, and reattach the new database.  Disclaim, disclaim, disclaim.  (Uncommitted transactions will be lost.)
Comment: Isn't the system disk... :-)
Comment: OF course: Msg 9002, Level 17, State 6, Line 1
The transaction log for database 'Earglue' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
Comment: I will try that a little later.  Thankfully, this DB is used as reference only, but we still do look at it quite a bit.
Comment: Okay, I stepped up the suggestion to something more aggressive.
Answer: Having experienced this problem just last week, I switched it to simple mode, but it would not let me shrink the database.  The solution I used was to turn the backup to Simple, then create a backup, which theoretically clears the log file.  On my server it did not, so I went ahead and restored the Database from the backup I had just created, then deleted the original once everything checked out.  My Database file size is now 25mb from 200gb.  The downside to this however is that you loose all your point in time backups (meaning your oldest backup is now what is currently running on your server).  It was not an issue for us, but may be an issue for you.

SQL Server 2005 Issue


why do continuations execute in an unpredictable order?

Question: If I chain continuations together they appear to be executing in an order I wasn't expecting.
For example:
for (int i = 1; i < 6; i++)
{
    HttpRequestMessage request = new HttpRequestMessage();

    Task<JsonResult<MyResult>> message = Task.Factory.StartNew<HttpResponseMessage>(() =>
        {
            Console.WriteLine(i + " started");
            return client.SendAsync(request).Result;
        })
        .ContinueWith<JsonResult<MyResult>>((r) =>
            {
                var stringresult = r.Result.Content.ReadAsStringAsync().Result;
                var deserialized = JsonConvert.DeserializeObject<JsonResult<MyResult>>(stringresult);
                Console.WriteLine(deserialized.Id + " deserialized");
                return deserialized;
            })
        .ContinueWith<JsonResult<MyResult>>(m =>
            {
                Console.WriteLine(m.Id + " completed");
                return m.Result;
            });

}

Now I'd expect to see the different requests interleaved, which I do, but I'm expecting to see each individual process execute in the order: started, deserialized, completed. However, sometimes the 'completed' continuation executes before the deserialization continuation, like so:

1 started
  2 started
  3 started
  4 started
  1 deserialized, length: 69
  1 completed
  5 started
  5 deserialized, length: 831
2 completed
  4 deserialized, length: 1022
  3 completed
  3 deserialized, length: 356
  4 completed
2 deserialized, length: 878
  5 completed

What am I missing here?
Edit:
Yes I know about the closure, the real code is much longer, and of course handles this, but I stripped out the guff that I didn't think was pertinent to the question, and then everyone goes and focuses on the missing guff!! It doesn't change the question or the issue I'm seeing.
Comment: Your code does not match the result. e.g. there is no length printed in the code. Also, the id:s printed are messed up. The first one prints the loop index, the second one prints something from the deserialization and the third prints the task id. You are not comparing the same thing
Comment: Is this your real code? I'm asking this because you're making the widespread mistake of closing over the loop variable. http://blogs.msdn.com/b/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx  This could lead to printing "5 started" multiple times.
Comment: I suspect some buffering/locking in Console.WriteLine(). Try adding a Stopwatch and printing StopWatch.ElapsedTicks to see if it really *is* doing what you think.
Comment: Since the code you've shown doesn't include a `length` in its `WriteLine` calls, it's possible that you've obscured the actual issue when anonymizing the code.
Comment: You also seem to have not gathered the intent of async programming.  You're doing a blocking wait on all of your async calls.  There is no value added in using your continuations you're using.  This is entirely synchronous code that just appears to be asynchronous.
Comment: I have edited your title. Please see, "[Should questions include "tags" in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not".
Comment: Which version of C# you are you using?
Comment: @Henrik if he's in C# 5 this shouldn't be the problem
Comment: To answer the comments, I stripped a whole load of code out, to try to get to the meat. The ids I'm really using are both consistent and not affected by the closure, but including all that code would have buried the core of the issue, none of which is related to the out of sequence continuations....
Comment: @MalcomTucker Well, given that there's no way for a continuation to run before the task it is continuing, it means that *something* is wrong, and it's most likely in how you log the information, not in how the code is running.  The only other option would be that your continuations start up a new async operation so it is completing the task before it's actually "done", but that's not what the code you showed does.
Comment: Servy - thanks, that last point is what I was assuming, and you're right actually right - it is completing the task before it's actually "done". Sometimes, at the point at which the completed continuation is executing, the deserialization step hasn't finished.
Comment: @MalcomTucker That's unlikely to be the case.  It would mean that you start a new thread/task inside of the continuation, which you don't do in the posted code.
Answer: As @Henrik says, by the time the thread runs, the value of i will have changed. This will make determining the order that the threads are actually running in look incorrect.
Try maybe passing the i in to the function:
  Task<JsonResult<MyResult>> message = Task.Factory.StartNew<HttpRequestMessage>(state =>  {

            Console.WriteLine(state.ToString() + " started");
            return client.SendAsync(request).Result;
        }, i )
            .ContinueWith<JsonResult<MyResult>>((r) =>
            {
                var stringresult = r.Result.Content.ReadAsStringAsync().Result;
                var deserialized = JsonConvert.DeserializeObject<JsonResult<MyResult>>(stringresult);
                Console.WriteLine(deserialized.Id + " deserialized");
                return deserialized;
            })
            .ContinueWith<JsonResult<MyResult>>(m =>
            {
                Console.WriteLine(m.Id + " completed");
                return m.Result;
            });

Comment: I know about the closure, it's all handled. The question still stands regardless - why are the continuations executed out of sequence?
Answer: You are not comparing the same id:s in your printout. Try changing the last continuation into
        .ContinueWith<JsonResult<MyResult>>(m =>
        {
            Console.WriteLine(m.Result.Id + " completed");
            return m.Result;
        });

so you at least compare the same id in the continuations.
Comment: The result Id is passed into the request (code not shown) so they are exactly the same ids.
Answer: So your largest problem is that you are doing a synchronous wait on all of your async operations (SendAsync and ReadAsStringAsync).  You're just doing these synchronous waits in a background thread.  There is no value gained from your ContinueWith calls at all, since all of your continuations have no asynchronous components to them.  You might as well just have your entire code inside of the original StartWith call; putting it in a continuation gains you nothing.
Here is an example of your program, but without the synchronous waits on the async operations:
for (int i = 1; i < 6; i++)
{
    HttpRequestMessage request = new HttpRequestMessage();

    int id = i;
    Console.WriteLine("{0} started", id);
    var result = client.SendAsync(request)
        .ContinueWith(t =>
        {
            Console.WriteLine("{0} reading", id);
            return t.Result.Content.ReadAsStringAsync();
        })
        .Unwrap()
        .ContinueWith(t =>
        {
            Console.WriteLine("{0} read", id);
            var deserialized = JsonConvert.DeserializeObject<JsonResult<MyResult>>(t.Result);
            Console.WriteLine("{0} deserialized", id);
            return deserialized;
        });
}

Also note that one problem in the code that you showed us is that you were not consistently using the same identifying number when logging to the console.  I have used the loop variable throughout, to keep it clear.  I also make sure to take a copy of the loop variable so that I'm not closing over the loop variable.  I also log slightly different things that should result in more interesting results.
Comment: Thanks for an answer that doesn't focus on the closed variable!! Where are the synchronous waits?
Comment: @MalcomTucker In your code?  The two calls to `Result`.  `Result` returns the result of the task, but if the task is not yet done it performs a blocking wait until the task finishes, so that it can get the result.  In both of those occasions you should be using `ContinueWith` instead so that you don't call `Result` until the task finishes, but without doing a blocking wait.
Comment: We're getting somewhere - the completed continuation is executing before the deserialization has finished. But why?
Comment: @MalcomTucker No, it's not.  I can assure you that it's not, unless your code is *nothing* like what's posted here, in which case who knows what's going on.
Comment: @MalcomTucker It means that the problem isn't that it's executing out of order, it simply means that you were improperly logging what was happening, so it *appears* out of order to you, even though it's not.  Regardless, you should restructure the code in a manor similar to what I have shown, because while your code won't run out-of-order, it has other significant flaws that need to be addressed.
Comment: sure, appreciate your time anyway, i've given you a +1 :)
Comment: when I remove the API calls and just use simple strings I'm seeing the expected behaviour
Comment: @MalcomTucker As you've clearly removed code that is relevant to what's going on we cannot intelligently comment as to what's going on, I can just tell you that a continuation won't be executed before the task that it continues is finished, so either it's running in the proper order and you are incorrectly observing the order in your logging, or your tasks are relying on asynchronous work and as such are being marked as "completed" before you want them to be done.  That isn't happening in the code that you've posted though.


How to query and space address with multiple values when some are NULL

Question: I'm trying to query and correctly format an address made up of multiple values in Oracle when some of those values are NULL. Coalesce() works well for this but not when I add spacing/punctuation.
Examples
address 1: 123 Main St
address 2: Apt 1
City: New York
State: NY
Postal Code: 10001
Country: USA

address 1: NULL
address 2: NULL
City: New York
State: NULL
Postal Code: 10001
Country: USA

When pulling in the full address, I'm wanting to ignore the subsequent punctuation if a value is NULL so there aren't excess commas/spaces.
select a.address1 || ' ' || a.address2 || ', ' || a.city || ', ' || a.state || ' ' || a.postal_code || ', ' || 'USA',
Coalesce(a.address1, a.address2, a.city, a.state, a.postal_code,'USA')
from address a

Example 1 Result: 123 Main St Apt 1, New York, NY 10001, USA
Example 2 Result: , New York,  10001, USA

Desired Result for example 2: New York, 10001, USA
This is just one example but I'm wanting a still properly formatted line when any combination of the elements are missing.
Comment: Just feed the address you build to regexp_replace, like this: `Regexp_replace(youradress, '^[ ,]+|[ ,]+$|, ?(?>,)') `.  This post-processes what you build looking for, and removing, all funny-looking punctuation.  It's a little subtle, using a lookahead in the middle section to remove multiple commas but retain at least one.
Comment: @ChrisMaurer - Oracle regex doesn't support lookaheads, unfortunately.
Answer: You could us the nvl2() function to append the comma and space to each column value, only if it is not null, and then just concatenate those together:
select nvl2(address1, address1 || ', ', null)
  || nvl2(address2, address2 || ', ', null)
  || nvl2(city, city || ', ', null)
  || nvl2(state, state || ', ', null)
  || nvl2(postal_code, postal_code || ', ', null)
  || 'USA' as address
from address

ADDRESS

123 Main St, Apt 1, New York, NY, 10001, USA

New York, 10001, USA

fiddle
If you weren't adding the fixed 'USA' at the end then you could end up with a trailing comma, which you could trim off.

... except I just noticed you don't want a comma between address1 and address2... you can handle that with a nested nvl2():
select nvl2(address1, address1 || nvl2(address2, ' ', ', '), null)
  || nvl2(address2, address2 || ', ', null)
  || nvl2(city, city || ', ', null)
  || nvl2(state, state || ', ', null)
  || nvl2(postal_code, postal_code || ', ', null)
  || 'USA' as address
from address

ADDRESS

123 Main St Apt 1, New York, NY, 10001, USA

123 Main St, New York, NY, 10001, USA

Apt 1, New York, NY, 10001, USA

New York, 10001, USA

fiddle (with added rows with just address1 or address2, as well as both/neither, for the output shown above).
Answer: Try:
REGEXP_REPLACE('Just concat without worrying about NULL','( ,)+', '')


Finding mean and variance of a population problem

Question: A population beings with a single individual.  In each generation, each individual in the population dies with probability $1/2$ or doubles with probability $1/2$.  If I let $X_n$ denote the number of individuals in the population in the $nth$ generation, how would I find the mean and variance?
So since the mean population size decreases geometrically when $\mu < 1$, wouldn't the mean be $\mu^{-n}$? To find variance would I just square the mean and use the variance formula then?
Answer: I think I'm calculating this wrong or guessing wrong  if calculations right but I think $E[X_n] = 1$ and $Var[X_n] = n-1$?
Reason for guess (not full proof if ever correct) is that I think:
$X_1 = 1$;
$X_2 = 0$, w/p=1/2,
$X_2 = 2$, w/p=1/2;
$X_3 = 4$, w/p=1/8,
$X_3 = 2$, w/p=2/8,
$X_3 = 0$, w/p=5/8;
...
Comment: Oh I was right? XD


Developing Stage Presence as Guitarists

Question: Where do I start to develop a good stage presence as a guitarist? While guitar-specific stunts (like the guitar spin, etc) are good to know, but I'm more interested in knowing general rules for movement (or, what's the best places in the stage to be in each part of a song, and the best time to switch between them), etc.
I'm also interested in which guitarists/specific live performances I should check out to watch analytically, and/or books (or other reading material) on the matter.
Comment: Noticed good or noticed bad?
Answer: Stage presence is a complicated thing, if only because it comes in so many varieties. If we were to compile a list of guitarists considered to have a great stage presence, we would probably find that no two are quite alike.
Let's start with the fundamentals - stage presence is the conveyance of feeling comfortable on stage and complementing your musical performance with the appropriate visual aspect.
'Appropriate' is a key word here. What will be considered appropriate depends on the music being performed. While a swing guitarist playing his ES-175 behind his head might get a few laughs these days, rather than being subject to horrified looks from the audience as would probably have been the case only a couple of decades ago, some forms of showmanship fit better with certain musical styles than others. Thus, a lot of what consitutes a good stage presence will be dependent on the genre in question.
There are some things common to just about any genre and this is what I want to focus on.
1. The appearance of confidence
This is stage presence at its most basic. Playing live consists of brief moments of bliss between problems of all stripes - from bad stage sound, through technical glitches, to moments of brain-freeze where you forget what you were supposed to be playing. Preparation can avert the most typical problems, but new ones will always materialise. It's simply part of the game.
Whatever problems we encounter, however, we must at all times endeavour to keep our composure and keep the audience unaware that something is wrong. They came to have a good time, after all. The most valuable skill a performing musician can learn is the art of quick recovery, followed closely by putting on a good face in a bad situation.
Confidence consists in knowing what you are playing, what you are supposed to be doing at various parts in the show (this may be as simple as "What is the next song on the list?" or as complex as a series of pre-choreographed movements, keyed to music and lights) and what you will do if something bad happens. Even if at some point you don't quite feel confident about any of those things, you must at least look like you're in control.
2. Situational awareness
When playing live you will be playing for other people and very likely with other people. Live music is a shared experience and conscious participation requires you are aware of what's happening around you.
A lot of beginning performers are so focused on getting their part right that they switch off as much of the on-stage environment as they can. In the worst case scenario, they might actually drift out of time, because they weren't listening to their bandmates. However, a musician that lurks in his corner of the stage, never lifiting his eyes from his instrument, is almost as bad.
You should have your parts down well enough that you can actually cast a glance around you. Situational awareness allows you to interact with the other musicians and with the audience. See that guy playing air guitar in the first row? Why not play up to him? Have a bunch of accents played in unison with the drums? Get up close and really play together. Are you playing lead under a vocal line? Why not lean in with the vocalist for that part? These are all rock cliches, I admit, but they're supposed to illustrate a thought process.
3. If you aren't enjoying yourself, the audience probably won't either
One point I always try to put across is that the live performer is in the business of providing entertainment. This means that you must avoid sending out bad vibes to the audience at all costs.
Now, we should quickly specify that what's at issue here are bad vibes about the gig. An aggressive, politicised punk or metal band may be expected to vent a lot of negative feelings about whatever gets their pressure up - the audience will be expecting this (hopefully). However, whatever personal, technical or reception problems we might have (sometimes the audience simply isn't buying us), we cannot let our negative feelings show.
Sometimes, this may mean putting on a fake smile, but it's something we owe our audience.
4. Develop your own onstage personality
We aren't actors, but our stage personna is an act to some extent. We remember Hendrix as the teeth-picking, guitar-burning, spaced-out Guitar God, but we'd be foolish to think that this describes him off-stage. The iconography remains, but we have to concede it shows only a small part of Hendrix the man.
Think about yourself as a person, yourself as a musician and yourself as a guitarist. Are you introverted or extraverted? Physical or cerebral? Emotional or rational? Are you a flashy, technical player or rather a melodic type, whose sound is all about feel? Or maybe you just like to rock out? Focus on the stuff that comes naturally and you'll find developing your onstage personna much easier.
5. See as many live performances as you can
I purposely avoid making any recommendations, since they are bound to be genre-specific and somewhat subjective. Moreover, any such list is bound to be incomplete.
Instead, here are some suggestions of what to look out for:

What is the impression you get from watching the musician in question? (You should be looking at all of them, not just the guitarists.)
Do you think it's appropriate/effective, given the music and the overall show?
How do the musicians interact with each other?
How do they interact with the audience?
How do they start and finish their songs? How do they develop them and what nuances of performance and showmanship do they use in key spots?
How is the setlist constructed? How do the musicians go from one song to the next? What's the flow of the show like? Do you think it's effective?

Note: You should pay particular attention to the beginnings and endings - in terms of both individual songs and the show itself. The start and finish are the most crucial elements. To quote Keith Moon: "They remember your entrance and your exit. The rest, in the middle, don't mean a goddamn thing."
6. Try to record videos of your own performances
For all our best intentions, we cannot see ourselves with the eyes of the audience until we put ourselves in the audience. Videos of your shows are to your performance what recording is to your playing.
Watching yourself on stage may be uncomfortable at first, but it offers great rewards in terms of critical evaluation. Use the same criteria as for reviewing other people's performance and look to improve those spots where you find yourself wanting.
Above all, have fun!

Developing Stage Presence as Guitarists


Can I remold an packed out pair of boot liners?

Question: I have a pair of snowboarding boots with a mold-able liner with about 4 seasons on them.  They are high quality boots and the fit used to be amazing. My feet were totally happy at the end of the day, but that's not the case any more.
Will re-heat molding them allow me to get another year out of them? What are the pros and cons to this approach vs. purchasing a new pair?
Answer: Usually people who have these kind of boots get this process done before they are worn. A lot of people say that doing this also decreases the lifespan of the boot. Older boots have the chance of the liner inside to start to break down over time which obviously makes it hard to heat mold them. Knowing that you have used these boots for 3 seasons and 3 seasons of wear have not maintained the shape of the liner, it might be time to move on.
But on the other hand, it wouldn't bankrupt you to try. Most ski and board shops offer this service at a relatively cheap cost. Between $15 and $40. Check with the shop you bought them at and you might get a deal.
To sum up. The pros of doing this is that it might actually work and you won't have to spend big money to purchase new boots. The cons of this is that you spend $15-$40 on the molding and or you have to buy new boots.


problema com soma parseInt()

Question: estou tentando somar mais "1" com parseInt() ao numero mas ele sempre me retorna o numero original com o "1" ao lado dele, por exemplo 10 + 1 ele me retorna 101 (acerto mizeravi). Obs: Estou usando o split porque na minha funçao completa eu retorno para varias div's diferentes valores diferentes.

 function teste(conteudo) {
      dados = conteudo.split('|');
      var adicicaoEstoque = parseInt(dados[1] + 1);
      document.getElementById(dados[0]).innerHTML = adicicaoEstoque;
 }
<button onclick="teste('resultado|10')">adicione + 1</button>

Answer: O correto seria primeiro converter o "10" e depois adicionar 1, senão ele faz a operação "10" + "1" que dá "101".
Veja assim:
var adicicaoEstoque = parseInt(dados[1]) + 1;

function teste(conteudo) {
    dados = conteudo.split('|');
    var adicicaoEstoque = parseInt(dados[1]) + 1;
    document.getElementById(dados[0]).innerHTML = adicicaoEstoque;
}
<button onclick="teste('resultado|10')">adicione + 1</button>

problema com soma parseInt()


Renomear anexos antes de salvar

Question: Senhores, tenho o seguinte problema.
Toda segunda feira, recebo de um sistema 12 e-mails, sendo eles:
SEXTA:

MIPS_1
MIPS_2
MIPS_3
MIPS_4

SABADO:

MIPS_1
MIPS_2
MIPS_3
MIPS_4

DOMINGO:

MIPS_1
MIPS_2
MIPS_3
MIPS_4

E preciso de um jeito em que eu salve esses arquivos em um diretório do computador, renomeando eles para que não substitua o arquivo atual.
Em algumas pesquisas, eu consegui o seguinte código:
Public Sub SaveAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
Dim f As Long
Dim NewName

'f = f + 1

' Get the path to your My Documents folder
strFolderpath = "C:\Users\brunoco\Desktop\Teste Macro MIPS"
On Error Resume Next

' Instantiate an Outlook Application object.
Set objOL = CreateObject("Outlook.Application")

' Get the collection of selected objects.
Set objSelection = objOL.ActiveExplorer.Selection

' Set the Attachment folder.
strFolderpath = "C:\Users\brunoco\Desktop\Teste Macro MIPS\"

' Check each selected item for attachments. If attachments exist,
' save them to the strFolderPath folder and strip them from the item.
For Each objMsg In objSelection

    ' This code only strips attachments from mail items.
    ' If objMsg.class=olMail Then
    ' Get the Attachments collection of the item.
    Set objAttachments = objMsg.Attachments
    lngCount = objAttachments.Count
    strDeletedFiles = ""

    If lngCount > 0 Then

        ' We need to use a count down loop for removing items
        ' from a collection. Otherwise, the loop counter gets
        ' confused and only every other item is removed.

        For i = lngCount To 1 Step -1
           For Each objAttachments In objMsg
            f = f + 1

            'If strSubject.Contains("VIDE") Then
            ' Save attachment before deleting from item.
            ' Get the file name.
            'strFile = Left(objAttachments.Item(i).Filename, Len(objAttachments.Item(i).Filename) - 4) + "_" + Right("00" + Trim(Str$(Day(Now))), 2) + "_" + Right("00" + Trim(Str$(Month(Now))), 2) + "_" + Right("0000" + Trim(Str$(Year(Now))), 4) + "_" + Right("00" + Trim(Str$(Hour(Now))), 2) + "_" + Right("00" + Trim(Str$(Minute(Now))), 2) + "_" + Right("00" + Trim(Str$(Second(Now))), 2) + Right((objAttachments.Item(i).Filename), 4)
            strFile = Left(objAttachments.Item(i).Filename, Len(objAttachments.Item(i).Filename) - 4) + "_" + Right((strSubject), 2) + Right((objAttachments.Item(i).Filename), 4)

            'If strSubject.Contains("VIDE") Then
            ' Combine with the path to the Temp folder.
            strFile = strFolderpath & strFile

            ' Save the attachment as a file.
            objAttachments.Item(i).SaveAsFile strFile

            ' Delete the attachment.
            'objAttachments.Item(i).Delete

            'write the save as path to a string to add to the message
            'check for html and use html tags in link
            If objMsg.BodyFormat <> olFormatHTML Then
                strDeletedFiles = strDeletedFiles & vbCrLf & "<file://" & strFile & ">"
            Else
                strDeletedFiles = strDeletedFiles & "
" & "" & strFile & ""
            End If

            'Use the MsgBox command to troubleshoot. Remove it from the final code.
            'MsgBox strDeletedFiles
          Next

        Next i

        ' Adds the filename string to the message body and save it
        ' Check for HTML body
        If objMsg.BodyFormat <> olFormatHTML Then
            objMsg.Body = vbCrLf & "The file(s) were saved to " & strDeletedFiles & vbCrLf & objMsg.Body
        Else
            objMsg.HTMLBody = "
" & "The file(s) were saved to " & strDeletedFiles & "
" & objMsg.HTMLBody
        End If
        objMsg.Save
    End If
Next

ExitSub:

Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub

Ele faz corretamente para o 1 primeiro dia, porem nos seguintes, ele substitui o arquivo, invalidando o que preciso fazer.
Gostaria de renomear para a seguinte forma:
SEXTA:

MIPS_1_SEX
MIPS_2_SEX
MIPS_3_SEX
MIPS_4_SEX

SABADO:

MIPS_1_SAB
MIPS_2_SAB
MIPS_3_SAB
MIPS_4_SAB

DOMINGO:

MIPS_1_DOM
MIPS_2_DOM
MIPS_3_DOM
MIPS_4_DOM

Agradeço a ajuda desde já!!!
Comment: Ele ja esta usando o .SaveAs
Answer: Você pode utilizar o seguinte código para realizar esta manipulação de string:
arquivo = objAttachments.Item(i).FileName
nome_arquivo = fso.GetBaseName(arquivo)
extensao_arquivo = Replace(arquivo, nome_arquivo, "")

If arquivo Like ("*MIPS_*") Then
    If j = 3 Then
        k = k + 1
        j = 0
    End If
    strFile = nome_arquivo & "_" & arr(k) & extensao_arquivo
    j = j + 1

Else
    'strFile = arquivo
End If

Se o anexo conter a palavra MIPS_ cria os arquivos na ordem, caso contrário salva somente o nome do arquivo em anexo.
Explicação

arquivo = objAttachments.Item(i).FileName é o nome do anexo, por exemplo: "Nome_Do_Arquivo.txt"
nome_arquivo = fso.GetBaseName(arquivo) é o nome do arquivo sem a extensão, ex.: "Nome_Do_Arquivo"
extensao_arquivo = Replace(arquivo, nome_arquivo, "") é a extensão do arquivo, ex.: ".txt"
strFile = nome_arquivo & "_" & arr(k) & extensao_arquivo concatena o nome final do arquivo que será salvo, com algum valor do vetor arr. O índice k do vetor é incrementado toda vez que 4 MIPS_ são salvos.

Código
Public Sub SaveAttachments()
    Dim objOL As Outlook.Application
    Dim objMsg As Outlook.MailItem               'Object
    Dim objAttachments As Outlook.Attachments
    Dim objSelection As Outlook.Selection
    Dim i As Long
    Dim lngCount As Long
    Dim strFile As String
    Dim strFolderpath As String
    Dim strDeletedFiles As String
    Dim f As Long
    Dim NewName
    Dim arr As Variant
    Dim j As Long, k As Long
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")

    ' Get the path to your My Documents folder
    'strFolderpath = "C:\Users\brunoco\Desktop\Teste Macro MIPS\"
    On Error Resume Next

    ' Instantiate an Outlook Application object.
    Set objOL = CreateObject("Outlook.Application")

    ' Get the collection of selected objects.
    Set objSelection = objOL.ActiveExplorer.Selection

    ' Set the Attachment folder.
    strFolderpath = "C:\Users\brunoco\Desktop\Teste Macro MIPS\"

    ' Check each selected item for attachments. If attachments exist,
    ' save them to the strFolderPath folder and strip them from the item.
    For Each objMsg In objSelection

        ' This code only strips attachments from mail items.
        ' If objMsg.class=olMail Then
        ' Get the Attachments collection of the item.
        Set objAttachments = objMsg.Attachments
        lngCount = objAttachments.Count
        strDeletedFiles = ""

        If lngCount > 0 Then

            ' We need to use a count down loop for removing items
            ' from a collection. Otherwise, the loop counter gets
            ' confused and only every other item is removed.

            For i = lngCount To 1 Step -1
                k = 0
                arr = Array("SEX", "SAB", "DOM")
                For Each objAttachments In objMsg
                    f = f + 1

                    arquivo = objAttachments.Item(i).FileName
                    nome_arquivo = fso.GetBaseName(arquivo)
                    extensao_arquivo = Replace(arquivo, nome_arquivo, "")

                    If arquivo Like ("*MIPS_*") Then
                        If j = 3 Then
                            k = k + 1
                            j = 0
                        End If
                        strFile = nome_arquivo & "_" & arr(k) & extensao_arquivo
                        j = j + 1

                    Else
                        strFile = arquivo
                    End If

                    'If strSubject.Contains("VIDE") Then
                    ' Combine with the path to the Temp folder.
                    strFile = strFolderpath & strFile

                    ' Save the attachment as a file.
                    objAttachments.Item(i).SaveAsFile strFile

                    ' Delete the attachment.
                    'objAttachments.Item(i).Delete

                    'write the save as path to a string to add to the message
                    'check for html and use html tags in link
                    If objMsg.BodyFormat <> olFormatHTML Then
                        strDeletedFiles = strDeletedFiles & vbCrLf & "<file://" & strFile & ">"
                    Else
                        strDeletedFiles = strDeletedFiles & "
" & "" & strFile & ""
                    End If

                    'Use the MsgBox command to troubleshoot. Remove it from the final code.
                    'MsgBox strDeletedFiles
                Next

            Next i

            ' Adds the filename string to the message body and save it
            ' Check for HTML body
            If objMsg.BodyFormat <> olFormatHTML Then
                objMsg.Body = vbCrLf & "The file(s) were saved to " & strDeletedFiles & vbCrLf & objMsg.Body
            Else
                objMsg.HTMLBody = "
" & "The file(s) were saved to " & strDeletedFiles & "
" & objMsg.HTMLBody
            End If
            objMsg.Save
        End If
    Next

ExitSub:

    Set objAttachments = Nothing
    Set objMsg = Nothing
    Set objSelection = Nothing
    Set objOL = Nothing
End Sub

Comment: Daniel, fiz o teste, mas ele acaba pegando os arquivos adiciona o _SEX e quando pega os outros dias, simplesmente substitui o arquivo, nao cria outros 8 com o _SAB e _DOM
Comment: @BrunoCovre Veja o edit
Comment: fiz as alterações no codigo, e agora ele salva 3 com _SEX e um com _SAB.
O nome do arquivo é esse : MIPS_SECP.txt , MIPS_SECD.txt , MIPS_VIDE.TXT e MIPS_ELO1.TXT.
Não sei se ajuda.
Comment: Veja como foi realizado esta manipulação de Strings, há outras maneiras de manipular também. Com isso você conseguirá realizar um código com base na concatenação realizada de exemplo.

Renomear anexos antes de salvar


WiX HEAT errors out when processing INI file

Question: I'm trying to use heat.exe (version 3.5.2519.0) to harvest a directory, which contains about 100 files and a few subdirectories. My command looks something like this...
heat.exe dir ./dir1/dir2/dir3/dir4 -sw5150 -out output.wxs

However, when heat.exe comes upon a particular .ini file in my directory, it errors out with the following Windows error dialog...
heat.exe - Application Error
----------------------------
The instruction at "0x04881351" referenced memory at "0x049795fc". The memory could not be "read".
Click on OK to terminate the program

I've isolated the problem to a particular INI file because when I modify any of the section/keys/values (e.g. change "SYNTH" to "SYNTH2"), heat runs to completion fine. The original INI file looks like this...
[PLUGIN]
SYNTH=MFiSynth.dll
AUDIO=MFiAudio.dll

Can somebody explain what heat tries to do with INI files in
general? Is it actually trying to read and process their contents?
What is it about my particular file that causes this memory access
error? And how can I get around this problem?

My wish and assumption was for heat to simply copy over files into a .wxs file and that's it, but it looks like it's doing more than that.
Answer: After much trial and error, I found that I needed to add the "-sreg" option to my heat command. This will prevent heat from actually processing the INI file (this also helped to resolve a similar issue I had with a particular DLL).


Adaptec configuration has changed - Why can't it show me what it sees before blindly "accept" or "reject"ing?

Question: I work with Adaptec cards on a regular basis; 2405, 5405, 6405e, 6805, and a few others.
I am dismayed by the BIOS' terseness and lack of any utility at all.
I can set card setting toggles; but the real issue I want to know:  What does the card see as the array?!
I had a working array.  Its a RAID1.
I then swapped the 2 disk cables, to see what would happen, and now its asking me to blindly accept or reject the configuration changes.
I can't even see what drives it thinks are there, without 'accepting' the change.
I don't want to 'accept' ANYTHING blindly.
What is the proper way to assess the current status of "what the RAID card thinks the disks are" ?
I then moved the cables back to the original disks, and allowed the BIOS to load again.  I did not accept anything, and instead allowed it to time-out.
The BIOS now shows a degraded array, with 1 "inaccessible" disk even though both are connected to the card now.
This is beyond broken by design.  What is the "proper" way to assess the status of 2 actual disks as to what the Adaptec RAID card thinks they are, before blindly acecepting or rejecting configurations?
The biggest issue is that "reject" disallows any and all viewing of the arrays, as it comes back "no arrays present".
What can be done to help a fellow not pull his hair out any further :)
Comment: If that is your problem wait until you see the new web based shiny non functional web frontend tht gives zero information about what is going on.
Comment: Newer adaptec controllers have less features in their legacy ROM than in UEFI. Do you have a mainboard capable of UEFI? If so, try to enable it and see if the controller menu appears inside the UEFI setup. It was the only way I could set up hot spares etc..
Answer: Greetings from Adaptec by PMC!
All the controllers you mentioned do store the physical device configuration in the NVSRAM on the controller.  The post message should give some indication of the configuration change i.e.:
Drive CN0 port 0 is no longer present
or similar.  If you have knowingly made a change to the physical drives attached it should be safe to accept the change assuming you have not removed more drives than your RAID level can tolerate.  If you have not made any changes to the drives then it's best to check the post message to see if you can determine the fault and reject the changes to review the "last known good" configuration.
If you'd like more information or further explanation, please open a case online at ask.adaptec.com or call to speak with a technician at 408.934.7274
Best Regards,
Adaptec by PMC Technical Support


Why divide by the square root of the number of p-values when calculating Stouffer's Z?

Question: If Stouffer's method of combining $k$ probabilities is based on the variance of the sum being equal to the sum of the variances, and the variance of $z$ is $1$, why does the Stouffer's formula divide by the square root of $k$ rather than by $k$?
Answer: This is to make the variance of the statistic equal to $1$. The statistic, $S$,  is a linear combination of independent $z$-scores:
$$ S = \frac{\sum_{i=1}^{k} Z_{i}}{\sqrt{k}} $$
so the variance of $S$ is
$$ {\rm var}(S) = {\rm var}\left( \frac{\sum_{i=1}^{k} Z_{i}}{\sqrt{k}} \right) = \frac{1}{k} \sum_{i=1}^{k} {\rm var}( Z_{i}) = \frac{1}{k} \cdot k = 1.$$
If you used $k$ instead of $\sqrt{k}$, you would get a variance of $1/k$.


Composer does not update anymore when trying to update to 8.4

Question: when I do an update with "Composer", the following error is displayed :

www.s1biose.com@vps000000:~/public_html$ composer update

<code>Cannot create cache directory /home/www.s1biose.com/.composer/cache/repo/https---packages.drupal.org-8/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/www.s1biose.com/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/www.s1biose.com/.composer/cache/files/, or directory is not writable. Proceeding without cache
Gathering patches for root package.
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install drupal/core 8.4.0-rc2
    - Conclusion: don't install drupal/core 8.4.0-rc1
    - Conclusion: don't install drupal/core 8.4.0-beta1
    - Conclusion: don't install drupal/core 8.4.0-alpha1|remove symfony/event-dispatcher v2.8.27|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.27|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.26|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.25|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.24|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.23|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.22|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.21|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|remove symfony/yaml v2.8.27|install symfony/serializer v3.2.10|install symfony/serializer v3.2.11|install symfony/serializer v3.2.12|install symfony/serializer v3.2.13|install symfony/serializer v3.2.9|install symfony/serializer v3.3.8|install symfony/serializer v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.20|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.19|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.18|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.17|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.16|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.15|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.14|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.13|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.12|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.11|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.10|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.0-RC1|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.9|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.0-RC2|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.0-RC1|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.8|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.0-RC1|install symfony/event-dispatcher v3.2.0-RC2|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.0-RC1|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.7|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.0-RC1|install symfony/event-dispatcher v3.2.0-RC2|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.0-BETA1|install symfony/event-dispatcher v3.3.0-RC1|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1|don't install symfony/event-dispatcher v2.8.6|install symfony/event-dispatcher v3.2.0|install symfony/event-dispatcher v3.2.0-BETA1|install symfony/event-dispatcher v3.2.0-RC1|install symfony/event-dispatcher v3.2.0-RC2|install symfony/event-dispatcher v3.2.1|install symfony/event-dispatcher v3.2.10|install symfony/event-dispatcher v3.2.11|install symfony/event-dispatcher v3.2.12|install symfony/event-dispatcher v3.2.13|install symfony/event-dispatcher v3.2.2|install symfony/event-dispatcher v3.2.3|install symfony/event-dispatcher v3.2.4|install symfony/event-dispatcher v3.2.5|install symfony/event-dispatcher v3.2.6|install symfony/event-dispatcher v3.2.7|install symfony/event-dispatcher v3.2.8|install symfony/event-dispatcher v3.2.9|install symfony/event-dispatcher v3.3.0|install symfony/event-dispatcher v3.3.0-BETA1|install symfony/event-dispatcher v3.3.0-RC1|install symfony/event-dispatcher v3.3.1|install symfony/event-dispatcher v3.3.2|install symfony/event-dispatcher v3.3.3|install symfony/event-dispatcher v3.3.4|install symfony/event-dispatcher v3.3.5|install symfony/event-dispatcher v3.3.6|install symfony/event-dispatcher v3.3.7|install symfony/event-dispatcher v3.3.8|install symfony/event-dispatcher v3.3.9
    - Conclusion: don't install drupal/core 8.4.0-alpha1
    - Conclusion: don't install drupal/core 8.5.x-dev
    - Installation request for drush/drush ^8.1 -> satisfiable by drush/drush[8.1.0, 8.1.1, 8.1.10, 8.1.11, 8.1.12, 8.1.13, 8.1.14, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.8.x-dev, 8.x-dev].
    - drupal/commerce 2.x-dev requires drupal/core ~8.4 -> satisfiable by drupal/core[8.4.0-alpha1, 8.4.0-beta1, 8.4.0-rc1, 8.4.0-rc2, 8.4.x-dev, 8.5.x-dev].
    - drupal/commerce 2.x-dev requires drupal/core ~8.4 -> satisfiable by drupal/core[8.4.0-alpha1, 8.4.0-beta1, 8.4.0-rc1, 8.4.0-rc2, 8.4.x-dev, 8.5.x-dev].
    - Conclusion: don't install drupal/core 8.4.x-dev
    - Installation request for drupal/commerce 2.x-dev -> satisfiable by drupal/commerce[2.x-dev].
</code>
What is going on ?
It worked before
Comment: The permissions? "directory is not writable" and also can you list your composer.json ?
Answer: I think the relevant error is <code>Your requirements could not be resolved to an installable set of packages.</code>
I had this too when I tried to update to 8.4.
If you're trying to run Drupal 8.4 you will need to use Drush 9, not Drush 8.
Change the drush line to:
<code>"drush/drush": "~9",</code>
And try again.
P.S. It's better to run <code>composer update drupal/core</code> and <code>composer update drupal/mymodule</code> one-by-one than to run <code>composer update</code> by itself.  <code>composer update</code> alone will update symfony dependencies before they have been tested for compatibility with core, which can break things.
Answer: I updated to Drupal 8.4 this way and that resolved composer requirement conflicts vis a vis Drupal and Drush, but Drush 9 was unable to recognize the running Drupal site as a running Drupal site:
<code> [error]  The command could not be executed successfully (returned:

  [Exception]
  Bootstrap failed.
</code>
Now that https://github.com/drush-ops/drush/pull/2800 is in, dropping back to <code>"drush/drush": "^8.0"</code> worked for composer dependencies and for Drush to actually find the site.
Answer: Requirement : PHP 7.1
Explanation :
1. Doctrire, a dependancy of Drupal core, requires PHP 7.1. Doctrine uses the latest PHP 7.1 syntax to declare the methods' return type eg. <code>function my_function() : void {...}</code>
2. webflo breaks the chain of dependencies
3. Drupal 8.4 requires Drush 9.0
If you have PHP 7.1 on your server you can do the following:

edit the <code>composer.json</code> file: <code>"drupal/core": "~8.4"</code> and <code>"drush/drush": "~9.0"</code>
delete <code>composer.lock</code>
delete <code>vendor</code>
update webflo: <code>composer require "webflo/drupal-finder ~1.0.0"</code>
update the database: <code>../vendor/bin/drush updb -y</code>
update the entities schemas: <code>../vendor/bin/drush entup -y</code>


Como usar o SimpleInjector em um projeto multi-camada?

Question: Imagine a clássica arquitetura:
ConsoleApplication (Frontend) --> Camada de Negócios (BLL) --> Camada de Acesso à Dados (DAL)
Ou seja, Frontend referencia BLL que referencia DAL. Veja que o Frontend não conheçe a DAL, e nem deve.
Dado que o o registro do meu container deve ser no Entry Point da aplicação (FrontEnd) como eu posso registrar uma dependência de um repositório da camada DAL se o Frontend não conheçe a DAL?
Imagine a seguinte estrutura:
DAL
<code>// Camada DAL
public class DAOPessoa : IDAOPessoa
{
    public DAOPessoa()
    {

    }

    public List<string> Obter()
    {
        return new List<string>() { "Pessoa 1", "Pessoa 2", "Pessoa 3" };
    }
}
</code>
BLL
<code>// CAMADA BLL
public class Processador
{
    private readonly IDAOPessoa _daoPessoa;

    public Processador(IDAOPessoa daoPessoa)
    {
        this._daoPessoa = daoPessoa;
    }

    public void Processar()
    {
        this._daoPessoa.Obter();
    }
}
</code>
FRONTEND
<code>//Um console application, por exemplo
public static class Program
{
    static readonly Container container;

    static Program()
    {
        // 1. Create a new Simple Injector container
        container = new Container();

        // 2. Configure the container (register)
        container.Register<IDAOPessoa, DAOPessoa>(); // Aqui fica sublinhado em vermelhor pois este assembly (Frontend) não conheçe nada da DAL

        // 3. Verify your configuration
        container.Verify();
    }
}
</code>
Existe algum padrão ou recomendação para resolver este problema?
Answer: Sim, você deve criar seu IoC como um CrossCutting. Ou seja, um projeto, DLL, que possuem cache dos registros, e que enxerga todos os projetos.
Você pode ver um exemplo aqui: https://github.com/thiagolunardi/EquinoxProject/blob/master/src/Equinox.Infra.CrossCutting.IoC/NativeInjectorBootStrapper.cs
Basta, então, adicionar o projeto de IoC no seu frontend e solicitar o registro no container.
No final, vc tem seu container de injeção de dependência com todos os registros necessários, seu frontend sem enxergar seu DAL
Comment: Isso mesmo. Assim vc tem um projeto de responsabilidade única.
Comment: Hum boa abordagem também, pelo que entendi então cria-se uma class library responsável pelo IOC referenciando todo mundo que for necessário? e o "FrontEnd" dele chama essa DLL e ela faz o trabalho?
Comment: Muito bom... Desde o início imaginei que essa seria a solução ideal, fiz a pergunta só pra confirmar e também porque vi vários post defendendo que o próprio frontend poderia referenciar tudo, nestes posts as pessoas argumentavam que referenciar a DLL de DAL, por exemplo, não necessariamente cria dependência entre os objetos, isso é verdade, mas é perigoso. A solução que vc sugere é muito mais elegante e segura.
Answer: Complementando a resposta do Lunardi, e olhando de outra perspectiva:

Criar um projeto de Infraestrutura e relacionar as dependências (esse é o ponto de "wiring" do seu DI);
Criar um projeto Core , possui os DTOs e extensões, e Contratos.
Criar seu console app (Frontend) e referenciar ao Infra e Core.
Criar seu BLL dependendo apenas do Core.
Criar seu DAL dependendo apenas do Core.


Do I need multiple db instances in Aurora cluster for write?

Question: I have a Aurora postgresql cluster in AWS and have one DB instance in this cluster. The postgresql DB is only used for write not for read. I use it as a backup database. I know Aurora has read scaling policy and I can create multiple DB instances in this cluster to improve read performance. But it doesn't benefit my case (write only). My question is that is there any benefits for me to spin up multiple db instances in the cluster. Aurura postgresql is a single master mode which means only one instance can take write. If I deploy multiple instances/replicas, they are basically useless. Do I understand it correctly?
Answer: Yes, you are correct. In your case there is no reason to launch additional instances in the cluster.
In the future, you may be able to use Aurora multi-master to give you more performance for writes. This is only available for MySQL 5.6 at the moment. See https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-multi-master.html
Comment: how about failure case? If I provision 3 instances, one for write, two for read. And if the writer is down, will the aurora cluster bring one of the read to be write?
Comment: Yes. If you are worried about a slow recovery if there is a failover then a second instance will speed that up. That setup is the equivalent of Multi-AZ in non-Aurora databases. The benefit in Aurora is that you can read from the standby instance, which is not possible in non-Aurora Multi-AZ.


Why is the probability that a bottle contains exactly one liter of water equal to zero?

Question: Let X be a continuous random variable, where X is the amount of water in a bottle in milliliters. The probability that there is between $900$ milliliters and $1100$ milliliters of water in the bottle is given by the following equation:
$P(900 ≤ X ≤ 1100) = \int\limits_{900}^{1100}f(x)dx$,
where $f(x)$ is the probability density function. Thus, if we want to know the probability that there is exactly one liter of water in the bottle we look at the following equation:
$P(1000 ≤ X ≤ 1000) = \int\limits_{1000}^{1000}f(x)dx$
Obviously, $\int\limits_{1000}^{1000}f(x)dx = 0$. So the probability that X is exactly $1000$, $1100$ or any value you choose, is always equal to zero. Note that this is true for continuous random variables and not for discrete random variables.
Question: What's the general intuition behind $P(X = 1000) = 0$? I always thought that it had to do with the fact that the random variable was continuous; for every $\epsilon > 0$, I can find a value between $1000$ and $1000 + \epsilon$. This illustrates how unlikely it is to pick exactly $1000$, but I don't know if this correct.
Thanks in advance!
Comment: well, this a good start to study measure theory~
Answer: If you choose a point from it-with uniform distribution-the odds of choosing any single point on the set is $0$.
Intuitively, it means that is not impossible, but it is highly improbable.
For example see this answer/question: "Is it generally accepted that if you throw a dart at a number line you will NEVER hit a rational number?"
Comment: $\mathcal L ([900,1100])=1100-900>0$
Comment: @TheoreticalEconomist Lebesgue outer measure obviously..
Comment: Sorry, but I'm confused. Any set that has outer measure zero is Lebesgue-measurable and has Lebesgue measure zero. Moreover the Lebesgue measure is the same as the outer measure whenever the former is defined.
Comment: @TheoreticalEconomist Done