How to find to the right strings of a barre chord by feel?

Question: I want to play a four-chord song: D -> A -> Bm -> G -> repeated.
D, A, and G are all open chords -- and B minor is a 5-string barre chord.
I'm practising (only having trouble with) the "A" to "B minor" chord change.
My difficulty is finding it (the strings for Bm) fast enough -- i.e. to complete the chord change from A to B minor in less than about half a second.
I can play Bm fine once I get there -- now I can change chord from A to Bm reliably in a bit less than one second, if I look at the strings.
I think my trouble is finding the right strings (i.e. index finger on the 5th string, middle on the 2nd, ring on the 4th and pinkie on the 3rd) -- unless I'm careful (and slow, and look at and adjust what I'm doing) my fingers go on the wrong strings, too high or too low.
I think the reason why I don't have that or any trouble with other (open, non-barre) chords (such as G, D, C, A, and E) is that my thumb is on the edge of the neck (i.e. on the top of the neck when the neck is horizontal and facing forward), so I position my fingers by feel relative to where the thumb is anchored.
However for a barre chord, my thumb is on (it moves to) the back of the neck (i.e. somewhere behind the neck as you look at it), it's moving (from the edge for the "A" to the back for the "Bm"), and thus isn't a reliably-positioned anchor relative to which I can position fingers.
How or relative to what do you position fingers and/or thumb and/or the hand on the neck, when moving to a barre chord?
I'm using a steel-string acoustic guitar (with the neck at about 45 degrees from vertical, standing and with a strap).
I've seen YouTube videos on how to make the barre chord shape, which give tips on how to press the index finger, position the elbow and the thumb -- but I don't know one on how to find the right strings quickly.

To be clearer about what I think the problem is: having practised, I more-or-less know and easily find the hand shape for the chord, what I can't find quickly is the hand position relative to the neck.
Consider these photos for example (take from here and here):

For the open chords, the thumb is on the edge of the neck, so each finger can find their string by feeling how far each finger is from the thumb.
Also the lowest portion of the index finger may be touching the other edge of the neck (which again gives tactile feedback about the position of the hand relative to the neck).
Whereas in the two barre chords i.e. F and especially Bm, the thumb is round the back -- and the back is smooth, rounded, featureless -- so the whole hand is lost in space, and doesn't know where it is relative to the neck.
The hand is moving a lot, too, for the transition: fingers are pointing almost vertically down the neck (all lined up on the 2nd fret) for the A chord, and horizontally across the neck (on the 2nd through 4th frets) for the Bm. For the open chords at least the thumb is in a more-or-less constant position, a kind of anchor.
Answer: Try using a method I find works with students. Put your fingers on the Bm shape, play to check. Take your hand off about 20mm, keeping the shape exactly. Then hammer everything back on Do it all in slo-mo the first 20 or so times, but each time, even if you can't make the whole chord sound just by hammering on, strum it. This imprints the shape of the chord into your hand, and eventually you'll think 'Bm', and the whole hand will morph into the appropriate shape. It's called 'practice', but it's targeted practice.
Comment: Carry on with my suggestion, but include moving from the previous chord shape, hammering on with both.
Comment: Thank you. Having practised, I almost have the shape (or can find the shape): it's finding the position on which to place that shape that I find difficult, i.e. landing the shape on the right strings, especially since (unlike in your exercise) I'm moving my hand, moving my thumb as explained in [this comment](https://music.stackexchange.com/questions/72413/how-to-find-to-the-right-strings-of-a-barre-chord-by-feel/72419#comment114496_72419).
Answer: Based on your description you are holding the neck incorrectly.  Thumb should be behind the neck not at the edge.  So you have created your own problem.  In addition to that there is no easy fix all for "finding a chord".  It takes practice!!!!!
You state that you can get from A to Bmin if you do it slowly.  Then practice slowly until it feels natural then speed it up.  Learning the guitar involves programming your nervous system to remember the feeling of each chord and each distance.
One thing that may help is how you're playing the A chord just before it.  If you bar the second fret and play the 4 middle strings you don't have to move to be in position for the Bmin.  This is a common method for open A modern guitarists use on electric guitar, but probably not the preferred method.
Comment: All chords should be easy to play with the thumb behind the neck.  I play all sorts of guitars and styles.  Thumb over the neck is valid fr some techniques, I have to do it to bend strings when playing blues.  But it shouldn't live there permanently, and there's no need to squeeze.  You'll never be mobile if you squeeze.
Comment: "Thumb should be behind the neck" is what I feared you might say -- both my (folk) guitar teachers place the thumb on the edge, even a bit beyond the edge where you might use it to mute the 6th string. Or [this video](https://www.youtube.com/watch?v=23KHLW2dw_o&feature=youtu.be&t=63) and [this video](https://youtu.be/GGMHSbcd_qI?t=114) clearly show the thumb, not hidden behind the neck.  The back of my guitar's neck is smooth and rounded so (unlike the edge) it doesn't give the thumb any tactile feedback about where on the neck (i.e. relative to the neck) it is: and so there's no anchor.
Comment: And having the thumb **across** (or around) the neck, tip of the thumb on the edge of the neck, tilts the hand relative to the neck, which makes it suitable for A-chord shape (i.e. 3 fingers on 3 strings on the same fret), for which the fingers must point somewhat down the neck; having the thumb **along** the neck makes it suitable for a barre shape (it un-tilts the hand), for which the index finger has to point across the neck (not down the neck).
Answer: I found a video ("Tip on how to do "Bm" Chord or transition to Bm") which recommends using the middle finger as an anchor: if the middle finger is in place (on the 2nd string) then the other fingers fall into place.
A clever way to transit from (specifically) A might be to play the version of A which uses the index finger to barre the 3rd and 4th strings on the 2nd fret, and the middle finger on the 2nd string of the 2nd fret -- so, that the middle finger is already on the 2nd string.
To get to Bm from there, the middle finger stays (anchored) on the 2nd string, simply slides down one from the 2nd fret to the 3rd fret, and other fingers fall into place (in the Bm shape) around it.


Heteroskedasticity: graphical visualization

Question: Often it is said that heteroskedasticty could be assessed in a graphical way: for instance it can be inferred by looking at the residuals of a regression. However, this seems to me quite discretionary. For instance, in the following pictures:

How would you say if residuals are homo- / heteroskedastic and to what extent? And based on what exactly?
Is there a best practice for this kind of analysis?
Comment: Possible duplicate of [Interpreting the residuals vs. fitted values plot for verifying the assumptions of a linear model](http://stats.stackexchange.com/questions/76226/interpreting-the-residuals-vs-fitted-values-plot-for-verifying-the-assumptions)
Comment: I think you will find the information you need in the linked thread. Please
read it. If it isn't what you want / you still have a question afterwards,
come back here & edit your question to state what you learned & what you still
need to know. Then we can provide the information you need without just
duplicating material elsewhere that already didn't help you.
Answer: As a complement to the plots that you show (and some others shown in the
answers linked on the right-hand-side of this page), a range-mean plot is easy to get and is often informative.
The idea is to split the series of residuals into blocks of length, say, $k=\sqrt n$, where $n$ is the number of residuals; i.e, the first block contains the residuals from 1 to $k$, the second one contains the residuals from $k+1$ to $2k$, and so on.
The mean and the range are obtained for each block and displayed in a graphic. If the variance is homogeneous throughout time, the points will be located around an horizontal line; otherwise, an increasing or decreasing (or a more complex) pattern will be observed.
As the residuals will, in principle, have a constant mean. It is better to
display the means of the times at which the observations are observed.

Example (taken from documentation of R package lmtest).
# Residuals of 'dy' in data set 'jocci' regressed on six lags
require("lmtest")
data(jocci)
fit <- lm(dy ~ dy1 + dy2 + dy3 + dy4 + dy5 +dy6, data=jocci)
e   <- residuals(fit)

As I said, as there is no trend in the residuals, the mean of the
blocks of residuals is not informative.
k  <- floor(sqrt(length(e)))
le <- split(e, gl(ceiling(length(e)/k), k)[seq_along(e)])
r  <- unlist(lapply(le, FUN=function(x) diff(range(x))))
m  <- unlist(lapply(le, FUN=mean))
plot(m, r, ylab="range (residuals)", xlab="mean (residuals)",
     main="range against mean of residuals")
abline(lm(r ~ m))

Alternatively, take blocks of the times of observations. It is observed that,
as we advance in the series of residuals, the range increases. A regression line shows a significant trend. This suggests therefore a heteroskedastic pattern.
par(mfrow=c(2,1), mar=c(4,4,3,3))
plot(e, type="h", main="residuals")
r   <- unlist(lapply(le, FUN=function(x) diff(range(x))))
lid <- split(seq_along(e), gl(ceiling(length(e)/k), k)[seq_along(e)])
m   <- unlist(lapply(lid, FUN=mean))
plot(m, r, ylab="range (residuals)", xlab="mean (times)",
     main="range of residuals against time")
fit <- lm(r ~ m)
abline(fit)
summary(fit)


Extend Block Class

Question: I created a block plugin that adds the ability to specify style settings by adding a form for configuring the styles.
Is it possible to extend the block class so that all blocks have this capability and not just the specific block plugin I created. Or is there a hook that can perform this action?
Answer: In general, you would use hook_form_alter() or hook_form_FORM_ID_alter() in a module to change all forms of a broad type.  For all blocks, it looks like the form ID is always "block_form".  So you can easily add elements to all block forms by implementing this function assuming your module is named "MYMODULE"
<code>MYMODULE_form_block_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
</code>
Since most blocks are extending BlockBase there is no way to change the class on the fly.
A really heavy-handed alternative to the form alter would be to use the decorator pattern and change all block plugins via the alter hook in discovery to use your class that adds some form elements and delegates most method calls back to an instance of the original class.
Answer: The Block Class module allows to add classes to every block.
To that, it uses a form alter and the third party settings support of config entities. The classes are then added through a template preproprocess.
The details can be found in the source code.

Extend Block Class


Does TcpInitialRTT value exist for Windows server 2012r2?

Question: I've some questions related to this parameter TcpInitialRTT.

Does this parameter TcpInitialRTT exist or name is changed in Windows server 2012r2?
I'm getting mixed information and being confused for example https://www.speedguide.net/faq/how-does-tcpinitialrtt-or-initialrto-affect-tcp-498 states TcpInitialRTT and InitialRto are same if so do you set TcpInitialRTT in registry and that would be output as InitialRto from PowerShell's Get-NetTCPSetting command?
Where can I find all the network related parameters that are supported in Windows server 2012r2, I've searched Google and not able to find the full list of network adapter/interface parameters that can be tuned for performance

The reason for my question is that here https://blogs.technet.microsoft.com/netro/2010/08/30/tcpip-stack-hardening-in-operating-systems-starting-with-windows-vista/ it states starting Vista they are no longer available so I'm assuming server 2012 came after Vista so it's applicable to 2012 as well?

If this parameter is not available in 2012 and say yet I set it here HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\interface\TcpInitialRTT what would happen? Would OS consider my set value or ignore?
Answer: Since I didn't get any response from SF, I asked the same at technet and here's what I got for reference:
https://social.technet.microsoft.com/Forums/office/en-US/00e3c024-51c4-4ba0-8502-29c18dc35539/does-this-parameter-tcpinitialrtt-exist-or-name-is-changed-in-windows-server-2012r2?forum=winserver8gen&prof=required


Proving that a function is integrable using the upper and lower sums

Question: Let $a$ be a number: $0<a<1$
I need to prove that the function defined as:
$
f = {1  :  x = 1/n, n\in N}
$
$
f = {0  :  otherwise}
$
is integrable in $[a,1]$ and that $\int_{a}^{1}f(x)dx = 0$.
I know that $f$ is blocked between $0$ and $1$. Therefore if I could prove that for every $\epsilon > 0$ there exists $P = {x_1,x_2,..x_n}$ in a way that
$S(P) - s(p) <\epsilon $ that would solve it.
Let $\epsilon >0$
in every $I=[x_i - x_{i-1}]$ $1\le i \le n$, there exists a rational number say $c$. therefore $\min(I) = f(c) = 0$.
Meaning that $s(P) = 0$
Now the problem I'm facing is that I now need to prove that $S(P) < \epsilon$
I know that at most, $\max{I} = 1$ and therefore, $maxS(P) = 1\cdot n = n$
But don't know how that can help me.
Answer: The argument below is not a fully formal proof, but it should be sufficient to initiate one.
Since the function is non-negative, it is sufficient to show that for every $\varepsilon>0$ there is a partition $P$ such that the corresponding upper sum is smaller than $\varepsilon$. The idea is to surround the points where $f$ equals $1$ by extremely small intervals. So, given $\varepsilon>0$, let $N_a$ denote the first integer for which $N_a>\frac{1}{a}$; then in the interval $[a,1]$, the points where $f$ equals $1$ are precisely $\{1/n\}_{n=1}^{N_a-1}$. Consider a partition of $[a,1]$, such that for each $1\leq n<N_a$, the point $1/n$ belongs to an interval of length $\frac{\varepsilon}{N_a}$, centered precisely at $1/n$, (except the point $1$, where the center is different). The total length of the intervals containing the points where $f$ equals $1$ is then less than $\varepsilon$, and the rest of the partition-intervals do not contribute to the upper sum, because $f$ vanishes on them.


vb.net, how to override users desktop font settings

Question: This seems like a dumb question, but i have looked ALL over and couldn't find an answer.
My problem is when i create a Simple VB.NET WinForm, with say a couple txtBoxes and Labels, then i goto test my .exe on another computer, and the user has some crazy script font thats like 36px and my program seems to inherit HIS font settings, not the ones i set.
Then when i open my program i see his crazy script font in the textboxes, and his font is so big you cant even read it...
How can i make my app NOT inherit Font or color scheme from the user ?? but what I set ??
I'm using Win7 x64, but i need this fix for XP to Win8
Comment: Are you setting the font in your Form
Comment: YES, i am setting ALL properties of the font before compile.
Comment: Is the font you are using present on the client computer
Comment: Is this a VB.NET or VB6 application?
Comment: YES, i am just using VERDANA, it's common pretty much everywhere, **BUT** his crazy script font takes over, i dont want that, i want the font I SET to be THE font.. and i am using VB.NET, but i am also using  VB6, is there any easy way to implement for both ?
Answer: Hope these links could help you ..
How can I embed font in Visual Basic .Net application?
http://zerosandtheone.com/blogs/vb/archive/2009/11/20/vb-net-include-a-font-as-an-embedded-resource-in-your-application.aspx


ssma Connection to Oracle failed. ORA-01017: invalid username/password; logon denied

Question: I try to migrate oracle database to sql server using Microsoft SQL Server Migration Assistant8.2 for Oracle, It is connected to sql server but it refused the login to oracle.
This is an image for the login form from ssma

and this is from the oracle sql developer and it connected successfully
Answer: There may be a password case sensitivity. An application can force a password and name in large case. The SEC_CASE_SENSITIVE_LOGON parameter gives control over case sensitive passwords.
Try to write a password in single quotes or change the SEC_CASE_SENSITIVE_LOGON parameter to false
alter system set sec_case_sensitive_logon=FALSE;
Check parameter SEC_CASE_SENSITIVE_LOGON.
select value  from  v$parameter a where a.name='sec_case_sensitive_logon'

------------
TRUE

For example.
create user test identified by TestPass;
grant connect to test;

oracle@esmd:~> sqlplus test/testpass

SQL*Plus: Release 184.108.40.206.0 Production on Thu Jun 13 06:33:25 2019

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied

Enter user-name: test/TestPass

Connected to:
Oracle Database 11g Release 22.214.171.124.0 - 64bit Production

SQL> exit
Disconnected from Oracle Database 11g Release 18.104.22.168.0 - 64bit Production

oracle@esmd:~> sqlplus test/'TestPass'

SQL*Plus: Release 184.108.40.206.0 Production on Thu Jun 13 07:14:17 2019

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release 18.104.22.168.0 - 64bit Production

SQL>

alter system set sec_case_sensitive_logon=FALSE;

oracle@esmd:~> sqlplus test/testpass

SQL*Plus: Release 126.96.36.199.0 Production on Thu Jun 13 06:35:11 2019

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release 22.214.171.124.0 - 64bit Production

SQL> exit
Disconnected from Oracle Database 11g Release 220.127.116.11.0 - 64bit Production
oracle@esmd:~> sqlplus test/TestPass

SQL*Plus: Release 184.108.40.206.0 Production on Thu Jun 13 06:35:35 2019

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release 188.8.131.52.0 - 64bit Production

SQL> exit
Disconnected from Oracle Database 11g Release 22.214.171.124.0 - 64bit Production
oracle@esmd:~> sqlplus test/TESTPASS

SQL*Plus: Release 188.8.131.52.0 Production on Thu Jun 13 06:35:47 2019

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release 184.108.40.206.0 - 64bit Production

SQL> exit
Disconnected from Oracle Database 11g Release 184.108.40.206.0 - 64bit Production
oracle@esmd:~>

Comment: Thanks so much. I reinstalled the last version of Oracle XE, Then It accepted the connection.


Como dar um select e jogar valores numa mesma coluna

Question: Exemplo:
select 'a' as 'letras', 'b' as 'letras'

Quero jogar a letra 'a' e a letra 'b' na coluna 'letras', porém com esse código ele retorna 2 colunas com o mesmo nome, porém quero jogar os valores na mesma coluna e não sei como fazer isso e nem como pesquisar.
Answer: Uma alternativa, é o UNION :
select 'a' as letras

union

select 'b'

Comment: Obrigado! Esse UNION me ajudou demais nas gerações de relatórios com alguns milhares de linhas rs


Drush not working on a docker based enviroment on ubuntu 16.04

Question: I have set up a local dev docker environment with the Drupal social distribution. My issue is that Drush commands do not work and whenever I run a Drush command, it takes approximately 45 seconds to get a response. Generally, the output is always the same or similar to the following.

[warning] proc_open(): unable to dup File-Handle for descriptor 2 - Too many open files exec.inc:243
  [warning] proc_get_status() expects parameter 1 to be resource, boolean given exec.inc:244
  [warning] proc_close() expects parameter 1 to be resource, boolean given exec.inc:245

I am unsure what the reason for this response is or what I may have done wrong to get to this point. I tried googling the warning errors but without getting a usable answer. If someone has had similar problems and managed to solve it, some directions on what to do would be appreciated.
I also want to state that outside the docker environment I have setup multiple Drush setups; Drush commands work normally without any delay outside of it.
My environment is Ubuntu 16.04 with 15.5 GB RAM, i7-6500U CPU 2.5 GHz x4 Processor, 200GB DDR disk.
I googled some more and found out that for running Drush inside a docker environment you need docker-compose run drush "drush command here" since Drush container gets run only for one specific command and then shuts back down, but now I am getting different errors.
docker-compose run drush cache-rebuild --verbose --debug gives this as output.

Phar detected. Proceeding to drush_main().Drush preflight prepare loaded autoloader at  [0 sec, 2.92 MB] [preflight]
  Starting Drush preflight. [0 sec, 2.92 MB] [preflight]
  Cache HIT cid: 8.1.2-commandfiles-0-9c75c37463d39480ab97163ab2be3712 [0.01 sec, 2.96 MB] [debug]
  Scanning into /etc/drush for /.*aliases.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into /etc/drush for /self.alias.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /.*aliases.drush(8|)rc.php$/ [debug] [0.02 sec, 5.02 MB]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /self.alias.drush(8|)rc.php$/ [debug] [0.03 sec, 5.03 MB]
  Scanning into /root/.drush for /.*aliases.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Scanning into /root/.drush for /self.alias.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Bootstrap to phase 0. [0.05 sec, 6.01 MB] [bootstrap]
  Bootstrap to phase 2. [0.05 sec, 6.01 MB] [bootstrap]
  Command cache-rebuild needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error] [0.05 sec, 6.01 MB]
  Command cache-rebuild requires Drupal core version 8+ to run. [0.05 sec, 6.01 MB] [error]
  The drush command 'cache-rebuild' could not be executed. [0.05 sec, 6.01 MB]

Hope that gives you a clue of what is the matter here.
Comment: Can you run your drush command with `--verbose --debug` and add the entire command log here? (omit sensitive strings of course)
Comment: i have very similar machine, I installed lamp and from terminal installed drush 8.1.8, and i have no issues at all
Comment: As I updated my question when discovering that drush need to be run in a different fashion inside docker, the problem persists of me not being able to resolve and drush commands and as @Joseph the Dreamer mentioned I tried to add verbose and debug to the command and am going to post the output into my question as new update.
Comment: Looks like you also use docker-compose. Can you post the `docker-compose.yml`? Also, post your alias file, if any.
Answer: When you run docker run ... or docker-compose run, Drush is running in the context of the container, not your host machine. So when it needs stuff like DB credentials, aliases, ssh keys, it looks for them in the container. If Drush cannot find such things in the container, Drupal cannot fully connect to Drupal and you get an error, usually the bootstrapping one.
I have a feeling your code isn't mounted to the Drush container, based on the fact that the alias scanning isn't picking up anything custom, only the usual alias paths. If the code is mounted, then probably the Drush container does not have the DB credentials. Do a drush status to check if everything is fine.


menu fixo com jquery em determinada rolagem (scroll) da página

Question: Estou tentando deixar este menu fixo https://jsfiddle.net/40ouwkcw/  a partir de determinada rolagem da página, neste caso, após a imagem inicial.
   Encontrei vários tutoriais no google, mas nenhum funciona no menu. Eu até tentei os perguntados aqui e também nada.

É difícil achar um menu igual o meu, e a maioria dos tutoriais são
  pra menus que comecem dentro de uma nav mas o meu começa em uma div
  talvez isso esteja influenciando em algo.

Enfim. Se puderem dá uma olhada e me ajudarem, ou me indicarem um site com um tutorial que você ache que vai se adequar ao meu, agradeço, pois todos que tentei não funcionaram.
Answer: Ok, faça assim:
Adicione um identificador à sua :
HTML

Criamos em CSS propriedades para uma classe que a #navbar vai ter quando o scroll for abaixo da imagem:
.fixed-menu {
   position:fixed;
   background:red;
   width:100% !important;
   z-index:9999;
   top:0;
   left:0;
}

E por fim JQUERY:
(function($, sr) {

     alturaImg = $('.imgTopo').height(); // altura da imagem, vai servir para sabermos a altura que o scroll tem de andar até a navbar ficar fixa
     $(window).on('scroll', function() { // cada vez de que fizer scroll o que está dentro desta função vai acontecer
          if($(window).scrollTop() >= alturaImg) { // se o que percorremos com o scroll for maior ou igual à altura da imagem adicionamos esta classe à navbar
              $('#navbar').addClass('fixed-menu');
          }
          else {
              $('#navbar').removeClass('fixed-menu');
          }
     });
....

Usando o seu exemplo, aqui está o jsfiddle
Comment: me desculpe mas eu não expliquei direito, eu mudei o link lá em cima, porque eu deveria ter colado alguma foto antes do menu, porque eu quero que ao passar por essa foto, o menu fique fixo.


Azure Data Factory - Add current time & random numbers

Question: In Azure Data Factory, I am preparing a pipeline for some data that I could like to run. I have a dynamic content script for the output of a Copy Data activity (attached are visualised data factory and output file).
QUESTION: When I add the timezone script, why does the output file in the blob storage show random numbers at the end of the file (i.e. the "7539827")? What can I do to remove this?
Following are the scripts for the original dynamic content and the script with the date.
Original Dynamic Content script
<code>@concat('     _',pipeline().parameters.SliceStart,"_')
</code>
Script with Timezone
<code>@concat('Test_',convertTimeZone(utcnow(),'UTC','New Zealand Standard Time'),'_')
</code>
Images:
visualised data factory ,
csv output in blob storage
Answer: Try mentioning the format like this
@concat('Test_',formatDateTime(convertTimeZone(utcnow(),'UTC','New Zealand Standard Time'),'yyyy-MM-ddTHHmmss'), '.csv')


How to Identify Sheet Music Type, Era, or Origin?

Question: Asking for some help here…maybe someone will recognize what kind of sheet music this is.
I'm attempting to recreate the framed sheet music hung on the wall in the photos. This is my father sometime in the late 70s or 80s. His big 60th bday is coming up soon and I'd like to recreate that poster he had framed behind him. I think it was something special to him, considering he had it framed, but I cannot for the life of me figure out what kind of sheet music it is, let alone what song it portrays. Any particular instruments or vocals shown here? I notice two treble clefs. Are the colored sections depicting frequencies? How do I interpret these measures, and go about discerning a melody?
Any direction or assistance is greatly appreciated.
Comment: @Aaron I see your point, but doesn't your answer ultimately boil down to "I knew the piece, so I was able to Google it"? In other words, is the "how-to" portion of your answer not just "know the piece"?
Comment: Voted to re-open. This is a how-to question, not an identification question.
Comment: @Richard That's fair, but the question itself does still fit our guidelines. My feeling is that closing it sends a mixed signal, especially to new users, who make an effort to meet site standards. I could get behind a more specific close reason so that there is some guidance for OP and others who come across the question.
Comment: Personally, I don't mind an easy identification question like this, but that is all it is. The only 'how to' about it is how to read music and then recognize the Beethoven motif. BTW, if it wasn't such a super famous motif, the picture is way to out of focus to do a read identification/score reading.
Answer: This is a portion of Beethoven's Fifth Symphony. The poster is titled "Sony Tape. Full Color Sound" (1979), by Milton Glaser (Wikipedia).
You can see a complete image at Milton Glaser Studio.
To identify it, I was able to see in the lower of the two systems that all instruments in the first two measures appeared to have the same "fate motif" rhythm as in Beethoven's Fifth. It also appeared that the second measure was a step lower in pitch than the first, again consistent with Beethoven's Fifth.
From there, I did a Google search for "Beethoven's Fifth Colorized poster", and the link the the Milton Glaser store was on the first page of results.
Comment: Mind blown. Seriously. I mean, sure the 5th is very famous, but still. I can't even identify anything remotely resembling a measure in that picture.
Comment: @Creynders If you haven't already, it helps to rotate the picture (or, in my case, the laptop). If you look at the bottom-most staff, you can reasonably make out a grouping of three eighth notes followed by a non eighth-note, then the pattern repeats.
Comment: Yeah ... but no, I really don't! :-)


Webform (*) instead of required word

Question: I have a situation I want to put (*) instead of "required" word inside the place holder of a webform field is it possible from webform admin.
Comment: Which version of webform module you are using ?
Comment: version 7.x-3.19
Answer: You can add this (*) in field label with field name or can use with style also.
Answer: You can always write a hook_preprocees_HOOK in your theme's template.php, in this case it would be
<code><?php
function THEME_preprocess_field(&$variables) {
   if ($element['#field_name'] == 'field_YOURFIELD' && $element['#bundle'] == 'webform' && $element['#view_mode'] == 'full') {
    $variables['theme_hook_suggestions'][] = 'field__field_WEBFORM_MY_TPL';
    $variables['ANOTHER VARIABLE_TO_OUTPUT'] = 'preprocessed';
  }
}
</code>
where you can manipulate the vars for this field, or even set your own template by copying the field tpl to your needs
Comment: So nice, you mean to say that there is no other option instead of using preprocess.
Comment: Hmm, no i don't say it's the only option.It is just the best option if you like to have everything controlled in your own code in a Drupal standards way.

Webform (*) instead of required word


Issues with user/system oracle role access and permissions

Question: I am having a bit of an odd issue when it comes to oracle roles and my schema creation code, I will do my best to describe my problem below:
On schema create a role is created using the schema name provided.
EXECUTE IMMEDIATE 'CREATE ROLE ' || USER || 'ADMIN_R';

This role is then granted to specific users associated with that schema.
DECLARE
    V_ROLE_NAME       CONSTANT VARCHAR2(30)   := USER || 'ADMIN_R';
    CURSOR C_ADMIN_USERS IS
        SELECT USERNAME FROM DBUSERS WHERE ROLE = 'ADMINISTRATION';
BEGIN
    FOR REC IN C_ADMIN_USERS
    LOOP
        EXECUTE IMMEDIATE 'GRANT ' || V_ROLE_NAME || ' TO ' || REC.USERNAME || ' WITH ADMIN OPTION';
    END LOOP;
END;

Users with this role have access to a special administration package.
EXECUTE IMMEDIATE 'GRANT EXECUTE ON P_ADMINISTRATION TO ' || USER || 'ADMIN_R';

The problem is When I drop the schema it does not drop this role (belongs to oracle), so when I recreate this schema the whole process fails because this role already exists. I also can't grant access to this role without logging into the system users which I want to avoid. The simple solution would be to just drop it, but my concern in that instance is that the DBA has been using that role to grant access to additional users and potentially additional packages, which would all be lost if we just arbitrarily drop the role to recreate it.
Any assistance would be greatly appreciated.
Answer: You could surround your role create with something like this:
SELECT COUNT(*)
INTO v_count
FROM DBA_ROLES
WHERE ROLE = USER || 'ADMIN_R';

IF v_count = 0 THEN
--grant your roles
END IF;

You can grant the same privilege as many times as you like.
Comment: I can't grant that role using the logged in user though, I would need to use the system user to grant it to the schema in this case. Which I want to avoid.
Answer: you can drop the role before create
declare
  i int;
begin
  select count(*) into i
    from dba_roles where role = USER||'ADMIN_R';

  if (0 != i) then
    execute immediate 'drop role '||USER||'ADMIN_R';
    dbms_output.put_line('Role ' ||USER||'ADMIN_R has been dropped');
  end if;

  execute immediate 'create role '||USER||'ADMIN_R';
  dbms_output.put_line('Role ' ||USER||'ADMIN_R has been created');

end;

1st try:
Role SCMADMIN_R has been created

2nd try:
Role SCMADMIN_R has been dropped
Role SCMADMIN_R has been created


Do we need the extra column in the augmented matrix of a LP?

Question: Consider the following linear program:
$$
\begin{array}{ll}
\text{maximize} & x_1 + x_2 + x_3 \\
\text{subject to} & 60x_1 + 20x_2 +50x_3 \leq 1 \\
& 20x_1 + 50x_2 + 10x_3 \leq 1 \\
\text{and} & x_1, x_2, x_3 \geq 0
\end{array}
$$
It has the following augmented matrix form:
$$
\left[\begin{array}{cccccc|c}
x_1 & x_2 & x_3 & s_1 & s_2 & z \\ \hline
60 & 20 & 50 & 1 & 0 & 0 & 1 \\
20 & 50 & 10 & 0 & 1 & 0 & 1 \\ \hline
-1 & -1 & -1 & 0 & 0 & 1 & 0
\end{array}\right]
$$
When solved, the matrix becomes:
$$
\left[\begin{array}{cccccc|c}
x_1 & x_2 & x_3 & s_1 & s_2 & z \\ \hline
\frac{26}{23} & 0 & 1 & \frac{1}{46} & \frac{-1}{115} & 0 & \frac{3}{230} \\
\frac{4}{23} & 1 & 0 & \frac{-1}{230} & \frac{1}{46} & 0 & \frac{2}{115} \\ \hline
\frac{7}{23} & 0 & 0 & \frac{2}{115} & \frac{3}{230} & 1 & \frac{7}{230}
\end{array}\right]
$$
As you can see, the $z$ column doesn't change. In practice I've seen that this is always the case. So, is there any need to keep the column $z$ around beside pedantic reasons?
I know that the solution is $\{ x_1 = 0, x_2 = \frac{2}{115}, x_3 = \frac{3}{230}, s_1 = 0, s_2 = 0, z = \frac{7}{230} \}$ which is why the equation $\frac{7}{23}x_1 + 0x_2 + 0x_3 + \frac{2}{115}s_1 + \frac{3}{230}s_2 + z = \frac{7}{230}$ holds true.
Answer: It's indeed alright to omit the $z$ column from the simplex tableau:

However, during the row operations of the SIMPLEX METHOD, this z-COLUMN never changes, and therefore Prof McFarland chooses to omit it to save time and space, and to simplify the appearance of tableaus. Any student may either keep or omit this z-COLUMN: the row operations will be unaffected whichever you choose.

However, there's a caveat:

The omission of a z-COLUMN has one cost: we must remember that in all simplex tableaus, the value of z is found in the lower right corner.


Is it possible to add custom property to CActiveRecord in yii?

Question: After use
$model=Table::model()->findByPk($id);

We can use
$p=$model->property;

to get property value. This property is corresponding to a table column, but I hope add one new property for $model which is not table column. Is it possible?
Answer: Yes it is possible. In your model after the
<?php

/**
 * This is the model class for table "{{table}}".
 *
 * The followings are the available columns in table '{{table}}':
 * @property integer $id
 .......
 */
 class Table extends CActiveRecord
 {

part you can define custom properties for your class. Like this:
class Table extends CActiveRecord
{
    public $aPublicAttribute;
    private $_aPivateAttribute;

You can reference these just like you reference the attributes that exist in your table.


how can I convert a negative log likelihood to likelihood?

Question: how can I convert a negative log likelihood to likelihood between 0 and 1 ?
I use HMMs package in R and  I keep getting strange results of the log likelihood for example, -48569 !
I need to understand these values so I can pick the best model.
any advice will be appreciated.
thanks
Comment: Simple answer: **you cannot**. First, because likelihood is *not* a probability. Second, if you are dealing with continuous data, then you have log-densities and (non-logged) densities are not in [0, 1] and cannot be "converted" to probabilities.
Comment: Your question is "I have $-\log L$, how do I get $L$". This seems to be a question of basic algebraic manipulation. Where's the difficulty in undoing those two steps?
Comment: thanks. I suppose there is a way to represent the values of log likelihood in much better ways. I want to train a discrete hidden Markov model not a continuous.
Comment: Still, likelihood is not probability. If it will "look nicer" for you you can exponentiate it, but it still will not be a "probability",
Comment: thanks , I have updated the question. My background is computing not statistics that's why I thought they are the same. but the purpose of my question is to get more understandable values of the likelihood. using the exponentiation gives me 0 !!
Answer: The log likelihood is the log of the likelihood. To get the likelihood from the log likelihood just take the exponential:
$$\text{Likelihood} = e^{\text{Log Likelihood}}$$
This should result in a very small number. Instead you can get the "avg. likelihood" by line in your dataset that is easier to interpret :
$$\text{Avg. Likelihood} = e^{\frac{\text{Log Likelihood}}{\text{Number of Lines}}}$$
Now, what I'm going to say may be true for most basic models, but not for every model.
For a discrete dependent variable $Y$, the likelihood is a probability between 0 and 1. For a continuous dependant variable $Y$, it is the value of the probability density of $Y$ and may not be smaller than 1. This can be interpreted as a probability by units of $Y$.
Anyway, this probability (or density) may not have a very clear meaning. It is not, like in Bayesian analysis, the probability that the parameters are correct. It is the probability that such data is observed given the fitted model.
Comment: What your are doing this way is create an increasing function from the log likelihood to get between 0 and 1. It is nice for visualizing it as a "score". But it is not a probability.
Comment: Are you sure that that's how you get the Avg. Likelihood??
Comment: thank you for your detailed answer. so what do you think if I did the following :  -48569 = log(1/48569) which gives -10.79074 , then convert log to probability using  10.79074/ (1+10.79074) = 0.91 .                  is this correct ?
Comment: No. The log of minus the log likelihood is nothing meaningful.
Comment: For the same kind of model (same way of computing the log likelihood), then a higher log likelihood means a better fitted model. The best fitting model is the one with highest log likelihood (sign must be kept, I mean -2000 is higher than -3000).
Comment: many thanks and sorry I make it a long conversation!  what if I keep getting better and better models ? when should I stop to avoid overfitting ?
Comment: It's another question. Browser for existing questions and maybe create a new one
Comment: @BenoitSanchez what exactly is meant here by "number of lines"? Do you mean for example in MCMC the number of draws?


How do you add help text to a form item?

Question: I would like to change the help text for an input field. My form ID is views-exposed-form-events-page-1. I have a text field that I want the helpful hint to appear below. The field ID is edit-field-event-date-value2, I think, based on the HTML.

From

<input class="form-control form-text" type="text" id="edit-field-event-date-value2-value-datepicker-popup-0" name="field_event_date_value2[value][date]" value="18/12/2019" size="20" maxlength="30" />
Date

 E.g., 18/12/2019

I thought that this would work, but I'm not seeing any help text appearing under the form field.
function mytheme_form_views_exposed_form_events_page_1_alter(&$form, &$form_state, $form_id) {
  $form['edit-field-event-date-value2']['#attributes']['description'] = 'DD/MM/YYYY';
}

What am I doing wrong?
Answer: The description doesn't live under #attributes, but under the element directly.
So you must do something like this to get it to work:
$form['field_event_date_value2']['#description'] = 'DD/MM/YYYY';

The HTML class is not the fieldname, but rather something like field_event_date_value2 in your case.
If that is not the correct fieldname, you can try to print_r(array_keys($form)) to see if you can see what the correct name is.
Comment: Thanks, I printed the array and yes the field name is field_event_date_value2. But I can't get it to work using the above code.
Comment: @MrFox Sorry `description` should be `#description`, I have updated my answer :)
Comment: Strangely that doesn't work either. I'm wondering if my function name is incorrect.
Comment: You can try to write a `mytheme_form_alter` and dump the `$form_id` to see what the form ID is for the form you try to alter.


Deploying on EC2 via SSH?

Question: At my job, I am required to deploy socks5 server on EC2 instances hosted on Alicloud (competitor to AWS). For each EC2 instance, I am required to do the following:

SSH to the IP of an EC2 instance
wget my socks5 server which is a perl script ,
execute this perl script.

I have to deploy about 50 EC2 instances a day. Aside from Docker (which I have been told is an overkill for my task), are there libraries or frameworks out there that allows me to do so?
EDIT
Fabric is a great tool
Comment: The term you want is "configuration management system". Puppet, Chef, Ansible, etc. are all useful for this.
Answer: You can use Packer to create images and then use Terraform to provision those instances. With packer you can use any configuration management software you want, salt, ansible, chef or puppet.
https://github.com/alibaba/packer-provider/tree/master/examples/alicloud/basic
https://www.terraform.io/docs/providers/alicloud/index.html
Comment: Thank you for recommending this super interesting tool. From a usage point of view, will this be easier than Fabric to get up and running?
Comment: I have never used Fabric but I can tell you that using both tools is really easy and convenient.
Answer: You can use Ansible (www.ansible.com) , an agent-less opensource configuration management tool.
It has already an integration with EC2 http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script in order to retrieve the manager server list and it use already
It use ad default ssh in order to connect and perform action on the managed servers.
The task 2 can be performed using the modules http://docs.ansible.com/ansible/get_url_module.html or  http://docs.ansible.com/ansible/copy_module.html
The task 3 can be execute using the module http://docs.ansible.com/ansible/command_module.html
Answer: I'm a bit surprised but here you can see the trends for the most popular deployment tools. Take into consideration that chef may be used in other contexts but I think that Ansible is becoming more and more popular because it is simpler.
Then it depends a lot on your usage, some opensource scheduler tools can give you more flexibility and will give you more flexibility.

Deploying on EC2 via SSH?


Custom rails environment log getting written to nginx error.log

Question: I have a custom environment for my app called staging.  For some reason, no staging.log file ever gets created, and all of the stuff that I would assume to be written there is instead showing up in the nginx error.log file.  Is there a configuration option that I'm missing?
Comment: possibly; also check permissions on the dir where the log would normally be created, it should be writeable by the user that rails is running as.
Comment: I checked the permissions, and they look fine.  The new_relic.log and the delayed_job.log file in the same folder have the same permissions. :(
Answer: This is an old question, but I just ran into the same issue and wanted to share what fixed it for me in case it helps anyone else who runs into this.
In my case, I was using the rails_12factor gem (because I had my app deployed on Heroku at one point), which causes all logging to go to stdout. This caused it all to get dumped into the nginx_error.log. I was able to completely remove the gem to fix it, since I don't use Heroku for the app any more, but if you need to support Heroku deployment you could add some sort of configuration so that rails_12factor only gets required in that context.
Answer: for logging in nginx you have:

the error_log directive, see http://nginx.org/en/docs/ngx_core_module.html#error_log
the acces_log directive, see http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log

there's one gotcha with the error_log:
if you have it set to debug, while your nginx is not compiled using the --with-debug flag, it will fallthrough to the default error.log location.
to check if your the flags your nginx was compiled with use the nginx -V command
Answer: Try adding something like
c = ActiveSupport::BufferedLogger.new("log/staging.log")
c.auto_flushing = true
config.logger = c

to your config/environments/staging.rb
Also you maybe should play with auto_flushing option, rails guide about configuration, says it's turned off in production env, I don't know why. See BufferedLogger docs here.
It doesn't look to me like perfect solution, but looks like it works.


QlikView: Can a SQL query be used in Expression of a List Box?

Question: I would like to create a List box which accepts an SQL query as an expression. Is it possible in QlikView?
For example, if I would like to display the Avg(sal) of all employees reporting to one Manager.
So, basically, list box should have the names of Managers and by selecting the manager, the average of sal can be viewed. Please suggest.
Answer: Any time you have a self referencing column in a table things can get dicey. To do this in Qlikview, the best solution is to create a managers table in the Qlikview script:
employees:
LOAD * INLINE [
    empnum, empname, man_empnum, salary
    1, Bill, 2, 50000
    2, John, 3, 75000
    3, Mary, , 115000
    4, Mike, 2, 45000
    5, Amy, 2, 58000
];

managers:
load distinct(man_empnum)
resident employees;

inner join(managers)
load empnum as man_empnum,
     empname as manname
resident employees;

This grabs a distinct list of only the manager employee numbers contained in the man_empnum field and then joins the appropriate employee name to each record. Only employees referenced as managers will show up in the managers table.
Once you have this in place you just need to create your list box. Grab the manname field from your "Select Fields" dialog, and then add min({1}man_empnum) in the Expressions tab. As I had previously mentioned in my old answer, you can add expressions to any list box with this procedure. Using min() in this case is just to ensure that the manager's employee number is always displayed in the list box. You'll see if you simply use man_empnum as the expression, the list box will only display the employee number of the selected manager. The important part is getting access to the set selector {1} so you can use any aggregation function you'd like in place of min. As long as you only ever have one employee number per employee, this will work.
Comment: Sorry for not adding full details. Lets say I have a table with EMPLOYEE details such as EMPNO,EMPNAME,MANAGER,SALARY. However, the MANAGER is not a name but an EMPNO who is in turn an EMPLOYEE in that table. So, basically there is a Hierarchy between Manager & Empno. In this scenario:                       1.I wanted to write an SQL query which gets list of MANAGER NAMES (EMPNAME) & EMPNO (i.e., EMPNO of each MANAGER) .       2.Now use that query as an input to a LIST BOX. Is this achievable ?
Comment: One other note, assuming all your employees are entered into your employees table, as long as it's hierarchical, there will always be at least one employee at the top who has no manager. In my example, Mary is at the top and therefore has no reference to a manager.
Comment: I am able to get the required output  only in 'Table box ' format. When I am trying to create a 'bar chart' or a 'Pie-chart',  with Dimension as "manname" & expression as '"avg(sal)", I see 'no data to display'. Can you please suggest if I am doing anything wrong here?
Comment: I've [uploaded a .qvw for you to check out](https://drive.google.com/file/d/0B7pnF70BI32KeXlVSTNLdDJmeVE/view?usp=sharing).You should be able to access it if you have a license. If you are using the free personal edition you won't, in which case, try this formula in your expression: `avg({1}aggr(avg({1}salary), empname))`.


AFHTTPSessionManager add body to POST

Question: I need too make a post request to my server.
With AFHTTPRequestOperation is very simple just use:
[request setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]];

However i can't find any example how use the same approach using the AFHTTPSessionManager.
Using the method:
[self POST:@"extraLink" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

} success:^(NSURLSessionDataTask *task, id responseObject) {

} failure:^(NSURLSessionDataTask *task, NSError *error) {

}];

How i add the the body to the "AFMultipartFormData"?
Thanks in advace
Comment: example: http://stackoverflow.com/questions/20686179/afhttpsessionmanager-header
Answer: As taken from the AFNetworking home page, to create a multipart/form-data request, you call appendPartWithFileURL:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendPartWithFileURL:filePath name:@"image" error:nil];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

But AFHTTPRequestOperationManager is deprecated. So, instead, use AFHTTPSessionManager, for which the syntax of POST with the constructingBodyWithBlock is very similar:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendPartWithFileURL:filePath name:@"image" error:nil];
} progress:nil success:^(NSURLSessionDataTask *operation, id responseObject) {
    NSLog(@"Success: %@", responseObject);
} failure:^(NSURLSessionDataTask *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

Alternatively, if you want to post a request of the form foo=bar&key=value&... (i.e. an application/x-www-form-urlencoded request), you would do something like:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSDictionary *parameters = @{@"foo": @"bar", @"key": @"value"};
[manager POST:@"http://example.com/resources.json" parameters:parameters progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
    NSLog(@"Success: %@", responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
    NSLog(@"Error: %@", error);
}];

Comment: Yes, you probably want to that (because AFNetworking will do the necessary percent-escaping that one needs to do for `application/x-www-form-urlencoded` requests). I guess you could create the percent-escaped body of the request yourself and then build the request yourself, but that's a lot more work.
Comment: There is another option to attach the data to the body? I have a string with a list "key=value&key=value&..." which is my body request. Do you know any way to add a plain string? @Rob
Comment: That `key=value&key=value&...` format is an `application/x-www-form-urlencoded` content type request (whereas the above creates a `multipart/form-data` request). If you need the `application/x-www-form-urlencoded` format, use the other rendition of `POST` without the `constructingBodyWithBlock` parameter.
Comment: sorry @Rob but I did not understand you fully. Can you give me an example of how to add the body using the other POST method? Thanks
Comment: just to confirm @Rob, i still need to convert my object "NSString" to a NSDictionary struture? Thanks
Comment: i get a warning 'Post:parameters:success:failure' is depreciated when i use the alternative example
Comment: @Edwin - Yep, it now has rendition with `progress` block. See revised answer.
Answer: Try this other way.
I'm converting my image in data format which is imageData.
NSData *imageData=nil;
imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"yourimageName"],0.2);
NSMutableDictionary *dict=[NSMutableDictionary new];
[dict setObject:@"user1" forKey:@"param_name1"];
[dict setObject:@"User2" forKey:@"param_name2"];

AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init];

[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
manager.responseSerializer = [AFJSONResponseSerializer
                              serializerWithReadingOptions:NSJSONReadingAllowFragments];
[manager POST:@"API NAME" parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {

 if(imageData)
 {
     [formData appendPartWithFileData:imageData  name:@"param_name" fileName:@"filename.jpg" mimeType:@"image/jpeg"];
 }
 } progress:^(NSProgress * _Nonnull uploadProgress)
 {
     NSLog(@"%@",uploadProgress);
 } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
     NSLog(@"%@",responseObject);

 } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
     NSLog(@"%@",error);

 }];

AFHTTPSessionManager add body to POST


matrix representation of this quotient map

Question: Let $F[x]$ be the vector space of polynomials over the field $F$. Define $L(f(x))= x^2 f(x)$. Let $x^n F[x]$ be all polynomials divisible by $x^n$. Then I know that $L$ induces a map of quotients $\overline{L}= F[x]/x^n F[x] \rightarrow F[x]/x^n F[x]$. What I have trouble with is finding the matrix representation of $\overline{L}$.

This is what I have worked out so far:
$F[x]$ has basis $\{1,x,x^2,x^3,...\}$
$x^n F[x]$ has basis $\{x^n, x^{n+1},...\}$
Hence, $F[x]/x^n F[x]$ has basis $\{1+ x^n F[x],\ x+ x^n F[x],\ x^2 + x^n F[x], ...,\ x^{n-1} + x^n F[x]\}$
So, for all $k$ such that $n-3 \geq k \geq 0$,
$\begin{aligned}
\ \overline{L}(x^k + x^n F[x]) &= L(x^k) + x^n F[x]\\
&= x^{k+2} + x^n F[x]
\end{aligned} $
\begin{pmatrix}
0 & 0 & 0 & \cdots & 0 & ? & ? \\
0 & 0 & 0 & \cdots & 0 & ? & ? \\
1 & 0 & 0 & \cdots & 0 & ? & ? \\
0 & 1 & 0 & \cdots & 0 & ? & ? \\
 & & & \vdots & & &  \\
0 & 0 & 0 & \cdots & 1 & ? & ?
\end{pmatrix}
However, what would the value be for $k = n-2$ and $k = n-1$?
Answer: Their values are $0$, and so all the ? in you matrix are $0$. Your computation shows for example $$\overline{L}(x^{n-2} + x^nF[x])=x^n + x^nF[x] = x^nF[x] = 0 + x^n$$ Same for $k=n-1$, since then you get the image of it under $\overline{L}$ is $x^{n+1} + x^nF[x]$. The point is $x^n$ and $x^{n+1}$ are divisible by $x^n$, so they are in $x^nF[x]$.


Mutliple left joins return double rows

Question: I have 4 tables

users
pictures
messages
friendrequests

I'm trying to get friend requests and new messages in a single query. It works well but as I left join 'friendsreuqests' I get multiple rows.
Here is my query:
SELECT username,
  f1.userid as reqId,
  m1.msg, m1.userid,
  p1.picHash, p1.extension, UNIX_TIMESTAMP( m1.sent ) AS date
FROM users
  LEFT JOIN pictures p1 ON p1.userid = users.id
  LEFT JOIN messages m1 ON m1.contactid = users.id AND m1.delivered =0
  LEFT JOIN friendrequests f1 ON f1.contactid = users.id AND f1.delivered=0 AND f1.request =1
WHERE users.id =7
ORDER BY date ASC

This is the MySQL result:
Kungen  3     gregegerg     1    dc825b1c8a35593be4d172db7    jpg    1369839537
Kungen  12    gregegerg     1    dc825b1c8a35593be4d172db7    jpg    1369839537
Kungen  3     HEJH          1    dc825b1c8a35593be4d172db7    jpg    1369839540
Kungen  12    HEJH          1    dc825b1c8a35593be4d172db7    jpg    1369839540

As you see there result is doubled. I want to get only two rows at this point. If I have two new messages but no new friends requests those 2 rows should be NULL.
Comment: Adding DISTINCT after SELECT will give you distinct results, but you actually have 4 distinct rows, so you'd either want to take an aggregate of the fields you don't care about, or not select them.
Comment: The description of the output you'd like is unclear, if you show us from those 4 output rows what you'd actually like, someone will nail it in seconds.
Comment: @Goat_CO look again -- the second column isn't distinct. Since that column (`f1.userid`) is the only one he's selecting from the `friendrequests` table, I suspect his real problem is in the data there.
Comment: distinct will not help
Comment: Not 100% sure, but moving `AND m1.delivered =0` and `AND f1.delivered=0 AND f1.request =1` into the where clause may help.
Comment: well, a user may have multiple friendrequests... So you have one line for each friendrequest (by user, with delivered = 0 and request = 1)
Comment: Your result isn't double. Watch closely: each line differs from each other line. The issue is your request, not the join.
Comment: @RyanNaddy: Given the data supplied, it won't make any difference - it would only be significant if some of the tables didn't have matching data (and they all do - there are no nulls in the observed output).
Answer: If you want to get friend requests and messages in a single query, then I would expect the query to have a union all.  Your query is doing a join between the tables.  This would add information about friend requests as additional columns.  You want it in additional rows.
I'm not sure which fields in the friends table correspond to which fields that you are requesting.  But here is an example of a query using union all:
SELECT username, users.id as reqId, m1.msg, m1.userid,
       p1.picHash, p1.extension, UNIX_TIMESTAMP( m1.sent ) AS date
FROM users LEFT JOIN
     pictures p1 ON p1.userid = users.id LEFT JOIN
     messages m1 ON m1.contactid = users.id AND m1.delivered =0
WHERE users.id =7
union all
SELECT username, users.id as reqId, NULL, NULL,
       NULL, NULL, UNIX_TIMESTAMP( f1.sent ) AS date
FROM users LEFT JOIN
     friendrequests f1
     ON f1.contactid = users.id AND f1.delivered=0 AND f1.request =1
ORDER BY date ASC

Comment: great! just have to edit the code a bit, but union all will make the difference for sure
Answer: If you LEFT JOIN  both friend requests and messages like you do you will get No of messages times number of friend requests in your result set. In you example you have 2 requests and 2 messages resulting in (2*2=) 4 rows.
Perhaps you should consider using a union instead? With a union you will be able to get one row for each friend request and one row for each message. That should suit your needs better.
You will still get 4 rows in your example (2+2), though.
Comment: tackar ;) det var det som behövdes
Answer: Adding GROUP BY clause with all fields in it will surely help, but you will have to decide, which value for second field you want to keep (3 or 12).
If you definitely know, that there are always 2 rows with that field differing, than you can select both MIN(m1.msg) and MAX(m1.msg)
Answer: The problem is that after the first two joins you get this if im right:
Kungen  gregegerg       1   dc825b1c8a35593be4d172db7   jpg     1369839537
Kungen  HEJH            1   dc825b1c8a35593be4d172db7   jpg     1369839540

now with joining the friendrequests table on f1.contactid = users.id you join the requests for user 3 and 12 on both entries with the userid 1 resulting in:
Kungen  3   gregegerg       1   dc825b1c8a35593be4d172db7   jpg     1369839537
Kungen  12  gregegerg       1   dc825b1c8a35593be4d172db7   jpg     1369839537
Kungen  3   HEJH            1   dc825b1c8a35593be4d172db7   jpg     1369839540
Kungen  12  HEJH            1   dc825b1c8a35593be4d172db7   jpg     1369839540

Now to get the right result you would need to join the friendrequests table on something that connects with the message or timestamp as this is the only column that differs.

Mutliple left joins return double rows


Views rewrite results: div in anchor

Question: I am trying to accomplish the following in a views accordion style.

Here is what I am putting in the rewrite field

[field_event_date_1]

[title]

[field_time_slot_1]

Here is what gets rendered

        Tuesday, November 3, 2015
Example title description goes here
1A - 10:00 - 11:30 AM

HTML5 spec allows div styling in anchors. Can anyone point me in the right direction?
Comment: If you don't use accordion, does the cessions classes get rendered?
Answer: If this was purely about just views accordian, then the rendering output you show would not be showing a div with a class of panel-heading. I see this as more likely about trying to have a views accordian rewrite into a panel and probably panels accordian at the same time and having the anchor tag reduced to a single line output when the html is stripped out. So without knowing what the full details are I can only suggest trying the rewrite as:
[field_event_date_1]
[title]

[field_time_slot_1]

or if only the div tags are being stripped out then try:

[field_event_date_1]

[title]

[field_time_slot_1]

Answer: I was using bootstrap accordion which the module strips out any markup.
Although I could hardcode the example, it was pointless to do so in that module.  I ended up changing my styling and using views accordion which allowed more grouping options.

Views rewrite results: div in anchor


Determinants Problem

Question:
\begin{align}\begin{vmatrix}(b+c)^2 & a^2 & a^2 \\ b^2 & (c+a)^2 & b^2 \\ c^2 & c^2 & (a+b)^2\end{vmatrix} = 2abc(a+b+c)^3\end{align}

Determinant             proof question-     Does anyone have an easy solution to this question?
Comment: We are not here to do computations for you. Show your work and where you are stuck. In particular, do you not know how to compute a determinant?
Comment: Yes,knew,but when i apply it here it becomes very lengthy,and it cannot be done.
Comment: You can apply the very definition of the determinant. The calcultaions will not be short, but it will be relatively easy. If you want a more elegant way, I'll give you the first step: try subtracting second and third lines from the first one.
Answer: Here is a slightly more "heuristic" way of getting the answer, which is still correct.
Note that if you put $a=0$ in the determinant, you get:
$$\begin{vmatrix}
(b+c)^2 & 0 & 0\\
b^2&c^2&b^2\\c^2&c^2&b^2
\end{vmatrix} = 0$$
As the 2nd and 3rd columns are multiples of each other. So you know that $a$ must be a root of the expanded form of the LHS. Further, it can appear only once since it only makes one pair of columns dependent. Similar reasoning for $b$ and $c$ tells you that $b$ and $c$ must also be factors of the RHS.
Also note that if $a+b+c = 0$, the determinant becomes:
$$\begin{vmatrix}
a^2 & a^2 & a^2\\
b^2&b^2&b^2\\c^2&c^2&b^2
\end{vmatrix} = 0$$
(by expressing $a+b$ as $-c$ and so on.) Now in this matrix three pairs of columns are dependent (pair-wise, of course), and so the factor $(a+b+c)$ must appear thrice on the RHS.
Now by mentally expanding the determinant with your focus on the exponent of the terms and not the coefficients, etc., you will see that all the exponents match, i.e. you are not missing any factors. So you know the RHS is a constant multiple of $abc(a+b+c)^3$. Setting $a=-1, b=c=1$ and expanding you will get that the constant coefficient is $2$ by comparison.
Answer: \begin{vmatrix}(b+c)^2 & a^2 & a^2 \\ b^2 & (c+a)^2 & b^2 \\ c^2 & c^2 & (a+b)^2\end{vmatrix}
Employing $C_1'=C_1-C_3,C_2'=C_2-C_3$
=\begin{vmatrix}(b+c)^2-a^2 & a^2-a^2 & a^2 \\ b^2-b^2 & (c+a)^2-b^2 & b^2 \\ c^2-(a+b)^2 & c^2-(a+b)^2 & (a+b)^2\end{vmatrix}
=\begin{vmatrix}(b+c+a)(b+c-a) & 0 & a^2 \\ 0 & (c+a+b)(c+a-b) & b^2 \\ (c-a-b)(c+a+b) & (c+a+b)(c-a-b) & (a+b)^2\end{vmatrix}
$=(a+b+c)^2\cdot$\begin{vmatrix}b+c-a & 0 & a^2 \\ 0 & c+a-b & b^2 \\ c-a-b & c-a-b & (a+b)^2\end{vmatrix}
$=\frac12\cdot(a+b+c)^2\cdot$\begin{vmatrix}b+c-a & 0 & 2a^2 \\ 0 & c+a-b & 2b^2 \\ c-a-b & c-a-b & 2(a+b)^2\end{vmatrix}
Employing  $C_3'=aC_1+bC_2+C_3$
$=\frac12\cdot(a+b+c)^2\cdot$\begin{vmatrix}b+c-a & 0 & a(a+b+c) \\ 0 & c+a-b & b(a+b+c) \\ c-a-b & c-a-b & 2(a+b)(a+b+c)\end{vmatrix}
$=\frac12\cdot(a+b+c)^3\cdot$\begin{vmatrix}b+c-a & 0 & a \\ 0 & c+a-b & b \\ c-a-b & c-a-b & 2(a+b)\end{vmatrix}
Can you take it home from here?

Determinants Problem


Ao clicar em um button radio, desabilitar o textarea

Question: Como faço para que ao clicar em um button radio que vem listado conforme as informações vindas de um banco de dados, desabilitar o textarea. Vejam abaixo:

Gostaria que ao clicar em Não, o textarea de justificativa referente, fosse desabilitado. O código inicial está dessa forma:
while($jmListar = mysqli_fetch_object($sqlListar)){
$listar .= "

                  <input name='Cancelar_$jmListar->IdCadastros' type='radio' checked='checked' value='S' id='sim'>
                  Sim

                  <input name='Cancelar_$jmListar->IdCadastros' type='radio' value='N' id='nao'>
                  Não

         	";
$listar .= "<textarea name='Justificativa_$jmListar->IdCadastros' class='form-control' id='justificativa' disabled></textarea>	";
$listar .= "
";
}

Answer: Você pode pegar o evento .change do radiobutton
<input ... class="rButton">
<input ... class="rButton">
<textarea id="justificativa">
Script

$( ".rButton" ).change(function() {
    switch($(this).val()) {
        case 'S' :
        $("#justificativa").prop("disabled", false);
            break;
        case 'N' :
            $("#justificativa").prop("disabled", true);
            break;
    }
});

Comment: Olá Danielle. A solução do dvd serviu para o que eu estava precisando. Muito obrigado mesmo assim.
Comment: blz. boa sorte..
Answer: Pode fazer desta forma:

$("input[type='radio'][name*='Cancelar']").click(function(){

   $(this).closest("tr")
   .find("textarea")
   .prop("disabled", $(this).val() == "S" ? false : true);

});

                  <input name='Cancelar_1' type='radio' checked='checked' value='S' id='sim'>
                  Sim

                  <input name='Cancelar_1' type='radio' value='N' id='nao'>
                  Não

<textarea name='Justificativa_2' class='form-control' id='justificativa'></textarea>

                  <input name='Cancelar_2' type='radio' checked='checked' value='S' id='sim'>
                  Sim

                  <input name='Cancelar_2' type='radio' value='N' id='nao'>
                  Não

<textarea name='Justificativa_$jmListar->IdCadastros' class='form-control' id='justificativa'></textarea>

Comment: Perfeito dvd. Funcionou! Muito obrigado mais uma vez.


Cascade dropdown list aka dependent dropdown list

Question: Is there any way to make a cascade dropdown list aka dependent dropdown list for a "survey" content type?
Apart from the "survey" content type. I have three other content types: country, state and district. Each of these types are linked by entity references.
In the "survey" content I have created 3 dropdownlists, one for country, state and district. I am filling these lists with content types that I created specially for each one, that is to say, one content type for country, another for state and another for district.
So far so good. But I would like that when I change one of them, the others change dynamically. I have been able to do it with views, but not dynamically. Is there any solution without programming?
Or is there another way to do this?
I have read countless blogs and sites. However, I have not been able to achieve this.
Answer: Yes, there is a way to achieve this. One of the best options is to use AJAX dependent drop-down. It requires custom code however. There are some good articles in the net which I saw solving this. You may find a very decent example in the examples module here
What it does is to build one dropdown and on changing its value, to calculate the options for the next one and so on. I used such technique several times in my projects already.
Good luck!


Cohen's d in proportion test

Question: I am calculating the sample size for proportion test.
I would like to have significance level =0.05, power = 0.90 and that the effect size is greater that 5%.
I would like to have statistically significance result if the difference in proportions is more that 5%.
But when I use pwr.2p.test function from pwr package to calculate sample size
pwr.2p.test(sig.level = 0.05, power =0.9, h=0.2, alternative="greater")

I have to specify effect size as Cohen's D. But it's range is said to be in (-3,3), and interpretation of this is:
The meaning of effect size varies by context, but the standard interpretation offered by Cohen (1988) is: cited from here
.8 = large (8/10 of a standard deviation unit)
.5 = moderate (1/2 of a standard deviation)
.2 = small (1/5 of a standard deviation)
My question is, how to formulate that I'd like to detect that there is more that 5% difference in proportions in 2 groups in a Cohen's d statistic?
Thanks for any help!
Answer: Are you constrained to the cohen's d approach? I've followed this site (http://ww2.coastal.edu/kingw/statistics/R-tutorials/proport.html) to do power tests recently. In my case I have a sense of the rates to expect in the samples and can plug in values for effect sizes I might encounter, so it may not work in your situation.
Comment: Thanks. I know what is the proportion of succes in control group and want to prove that the proportion in experimental group is at least 5% Higher :) so maybe it will work

Cohen's d in proportion test


Acoustic guitar - how to wind strings on the tuning posts

Question: While writing an answer to this question, I did a little web searching and found that the way I was taught 29 years ago to wind the strings isn't necessarily the best.
On an acoustic guitar, I tend to wind enough string on the posts that they're pretty much covered up completely, winding once under the string hole and the rest of the times over, avoiding any doubling back or other messiness. Is this still recommended? Is perhaps the Taylor way reflective of current thought? Is this question something that can be reasonably answered, or is this simply a matter of taste? (Edit: I'm particularly interested in that last one.)
Comment: For what it is worth: I wind around maybe 3 times, and then pass through the peg. Bring up the tension and then clip the excess. When I first learned to change strings, I did what the Taylor Way video shows (peg first, then wind) and the high E string snapped under tension every time...
Answer: I pretty much agree with everything in that video, except not everyone is as lucky to have an automated winder :)
So here is what I do (on an acoustic guitar, anyway):
After removing the old string and fitting the new string:

I slide the end of the string through the post, until it is taut, and then pull it back so that it has 1-2 inches of slack. I then bend the point of the string that is just through the post (leaving the string with 1-2 inches of slack behind it). This bend creates a crook in the string, and this stops the string from slipping through the post while you are winding it.
On the higher pitched strings I usually give the string that is beyond this crook a wind or two around the post, just to give the string a bit of extra grip so that it does not slip as it is being wound.
I then wind, until the string is at full tension at roughly the right pitch. Only then do I cut the surplus end off.
This is because: if you have too much/too little wound around the post, and need to go back and rewind, it is trickier to go back and rewind from scratch if there is no extra length past the post for you to create a crook in to stop it moving as you wind it.
A note: on the strings where the gauge is thicker (in this case the low E and A strings) it is important to not wind too much around the post, or the thickness of the winding of the string will stick out and distort the adjacent string next to it.

Hope this helps.
Apologies if this is unclear, post a comment if you need further clarification, thanks :)
Comment: I had one of those winders years ago, but lost it in a move. Nice explanation, and it seems clear to me.
Answer: I agree with most of what Alistair says but I use a hand-width of slack on the low strings (gives about 3 wraps on the E, 3 on the A, 4 on the D) and then I put even more slack on the lighter strings by spreading my fingers (I count about 5 on the G, 8 on the B, and too many to count on the E without standing up and walking over there).
All these extra wrappings provide extra pitch stability. When I tune it up (takes a few times to stretch 'em in), it stays tuned until the weather changes.
Also you can coil the excess length instead of clipping. When clipped too short, those suckers are sharp! Not kid/finger/cat-friendly!
Answer: Think of tying a knot: http://www.tollesburysc.co.uk/Knots/Clove_hitch2.htm
The only difference being that you need to put the string through the middle of the post and wrap it around two more times in order to really tighten it up from the bottom up.  In other words use that knot, but as you wind it for the second and third time, push the string to the bottom of the knot in order to push the know in on itself from the bottom of the hole in the peg.  Any extra string: grab the string between your thumb and forefinger from the tuning peg, pinch and pull towards the end of the string - it will curl in on itself for the E,B,G and D strings. For the A and Low E, clip'm about 1/2 inch away from the tuning peg - if you wind tight enough or use a locking nut, you will be OK.....
Answer: I always used to use the Taylor way and go for the three loops but I recently read this article suggesting to use as little string as possible as this helps with tuning issues and I have preferred this method to be honest. You can have a look here. It might just come down to personal preference and I haven't met a tech yet who has told be there is clear evidence either way so best to be open minded I guess?


How to get input from textarea in html to .ts in Angular

Question: I am a newbie in Angular and now I want to get user input from a textarea but I fail to do so.
Updated: ng-model="num1" > [(ngModel)]="num1"
HTML:
<input [(ngModel)]="num1" type="text" placeholder="Enter value">
     // user enter one number

<input type="text" readonly value={{answer}}>

<button class="result" (click)=onSelectEqual()>=</button>
     // click this button to get the value that user entered

.ts:
num1 : number;
answer: number;

onSelectEqual(){
  this.answer = this.num1 + 1 ;
}

Comment: A gentle reminder:   AngularJS == versions 1.x; Angular  == versions 2+. There is no such thing as AngularJS 8.
Comment: Is it angular or angularJS? In angular you have to use `[(ngModel)]="num1"`
Comment: you are mixing `angular` and `angularJS`. The `click` event is called using angular syntax. In angularJS,  it should be `ng-click="onSelectEqual()"` - https://docs.angularjs.org/api/ng/directive/ngClick.
Answer: In angular, for two-way binding you have to enclose ngModel in [()]. See - https://angular.io/api/forms/NgModel.
<input [(ngModel)]="num1" type="text" placeholder="Enter value">
Answer: Use [(ngModel)] instead of ng-model in your html template. ng-model is the syntax of Angularjs which will not work in Angular2+.
Also make sure to import FormsModule in app.module.ts
import { FormsModule } from '@angular/forms';

Also add it to the imports array in app.module.ts
imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule
  ],

This is important as without the FormsModule, angular will not be able to identify the ngModel directive.
On a different note, the input will return the value typed by the user as a string. To read it as a number and add 1 to it, you will have to typecast it:
onSelectEqual(){
  this.answer = Number(this.num1) + 1 ;
}

Please also note that // for comments doesn't work in html template, use  instead.


Nginx SSL Termination - How to encrypt data to client?

Question: I've setup a Nginx as a HTTP load-balancer with SSL/TLS termination for apache webservers. My question is by using Nginx to terminate ssl how do I encrypt the data back to the browser/client.
Does each apache server have to be configured to do SSL or is the data sent from apache back to Nginx for encryption? I would like to limit CPU resources on the apache webservers.
Thanks for any help on this issue.
P.S.:I'm using X-Forwarded-For on my Nginx config. Does that send the browser's certificate to the apache servers?
Comment: X-Forwarded-For sends the client's IP address rather than the proxy's IP address. You still need to edit your Apache logging though in order to register the client's IP address. i.e. LogFormat "%{X-Forwarded-For}i ...
Answer: You have two entirely separate connections. The connection from the web browser to nginx is encrypted with SSL, and so nginx has to be configured for SSL. The connection from nginx to Apache to retrieve the data for nginx to send to the browser should be a regular http connection with no SSL, so Apache doesn't need to have any SSL configuration.
Comment: "The connection from nginx to Apache to retrieve the data for nginx to send to the browser should be a regular http connection with no SSL" provided you are on a private VLAN.
Comment: The data from nginx to apache is unencrypted. So any data from apache to nginx will be encrypted by nginx?
Comment: No, the data from the client/browser to nginx will be encrypted provided nginx has been configured appropriately. nginx then proxies the requests (unencrypted) to the Apache web servers.
Comment: Yes but what happens to the data from apache? Does apache send it unencrypted (because it's not configured for SSL) back to the client or does apache sent the data back to nginx, nginx encrypts it and send it back to the browser? That's my question.
Comment: nginx decrypts the data coming from the client, send it unencrypted to Apache. Apache sends unencrypted data to nginx, which then encrypts it before transmitting it to the client.


Rails: Stripe Button not working on first attempt (until page is reloaded)

Question: I have a rails app with a custom checkout where user clicks a button to launch Stripe modal.
Problem is that when I first visit the page and click the button, I get this error:
"Invalid source object: must be a dictionary or a non-empty string"
The error is coming from my controller create action:
customer = Stripe::Customer.create(
          email: params[:stripeEmail],
          card: params[:stripeToken]
        )

But then if I refresh the page instead, I can launch the modal with no issue. I thought it might be a turbolinks issue, so I added my script in a ready var:

But not fixed. It seems like the e.preventDefault() isn't working when the page is first loaded... But I'm not sure why.
Answer: I had a similar problem with implementing a custom form with Stripe.  What worked for me was to move from the application layout:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag "https://js.stripe.com/v2/" %>
<%= javascript_tag "Stripe.publishableKey = '#{STRIPE_PUBLISHABLE_KEY}';" %>

to the actual view file (ex. new.html.erb) at the bottom of the page so it would be just above the ending tag.  This means I will have to include application.js on every view not via application layout so I will probably add it to the footer.  Not sure if this is the best way, but it worked for me.
Comment: We've done the same, we have moved the JS to be inside the HTML file that renders the form, but sometimes it needs to be refreshed, any other ideas?


Let $f:X\to X $ be continuous. Does $f $ have a fixed point when $X=[0,1)$ or $X=(0,1) $?

Question:
Let $f:X\to X $ be continuous. Show that if $X=[0,1] $, $f $ has a
  fixed point(i.e. there exists  $x$ such that $f (x)=x$). What happens
  if $X $ equals  $[0,1) $ or $(0,1) $?

First part of the question is an immediate consequence of intermediate value theorem(for a proof, see here). I think $f (x)=x^2$ is a counterexample when $X=(0,1) $, since $x^2\lt x $ for all $x\in (0,1) $. But to be honest, I don't understand what causes breakdown of the fixed point theorem on $(0,1)$, since IVT only requires connectedness of domain. Is this related to the non-compactness of $(0,1)$?
Also I can't think of any counterexample for the case $X=[0,1)$(assuming fixed point is somehow related to compactness).
Any help is appreciated.
Thank you.
Comment: A circle is compact and connected. But a rotation of it by $180^o$ about its center is a continuous map with no fixed point.
Answer: The IVT is not the only ingredient here. The way the theorem works is by setting up this square:

where the line in the middle is $y = x$. A function from $[0, 1]$ to $[0, 1]$ that intersects this line will have a fixed point at the point of intersection.
The IVT kicks in when we have a function whose graph enters the top triangle and the bottom triangle at various points, e.g.

The fact is, by the IVT, the function has to cut the line somewhere, i.e. it must have a fixed point.
But, this makes an assumption! The function may only exist in one triangle or the other, but not in both. That is, why can we not have $f(x) > x$ for all $x$ or $f(x) < x$ for all $x$?

The picture above illustrates it. Due to the function having a full domain of $[0, 1]$, there's a squeeze happening. The green function is about as close as we can have to a function satisfying $f(x) > x$. Similarly, the red function attempts to have $f(x) < x$. But, both are pinched towards the diagonal line. The green function must have $f(1) = 1$, and the red function must have $f(0) = 0$.
This illustrates the necessity of defining all the way to $0$ and $1$. Removing either of these points means that the functions are not squeezed to a fixed point (we'd only ensure that $f(x)$ and $x$ become arbitrarily close).
Comment: what about when we define the function on $[0,1]$ but the function is not continuous, I was able to come up with the following example $f(x) = 1/2$ for $x = 0$ and $f(x) = x/2$ otherwise, is this a correct counter example???
Comment: @user601297 Yes, that's a correct counterexample.
Answer: The compactness is not really used in proving the FPP for $[0,1]$. We do use both endpoints (we use $f(0) >0$ and $f(1) <1$ when $f$ has no fixpoint in $\{0,1\}$ which then triggers the IVT). You could say that compactness forces these endpoints to be in your set.. (compact and connected in $\mathbb{R}$ means homeomorphic to $[0,1]$).
So to find a counterexample, look for functions on $[0,1]$ with a unique fixed point that is either $0$ or $1$. Then removing that point makes a counterexample. $f(x) = \frac{1}{2}x$ is an easy one for $X=(0,1]$ e.g.
Answer: $$f:[0,1) \to [0,1), x \mapsto  \frac x2 + \frac12$$
$$f:(0,1) \to (0,1), x \mapsto  \frac x2 + \frac12$$
If $x = f(x)$, then $x = 1$ which is not in the domain of $f$.
$$f:(0,1] \to (0,1], x \mapsto \frac x2$$ also has no fixed points.


Overview & help with drupal files and folders on Win 7

Question: I am a newbie. Please forgive me if this is a dumb question.
I'm trying to wrap my brain around what is Drupal and how it works.
I installed Acquia Dev Desktop successfully on my Win 7 computer. I want to make sure that I backup all files and folders, but have discovered that Drupal/Acquia is scattered just about everywhere on my hard drive. I found the following (where "Sam" is my Win 7 username).

C:\Program Files (x86)\DevDesktop
C:\Users\Sam\Sites
C:\Users\Sam.acquia
C:\Users\Sam.drush

Have I missed any locations? Why is everything not consolidated in one folder? It would make life much easier!
If this is not the proper forum for dumb questions please tell me a better place to post.
Thanks!
Answer: The confusion is probably resulting from things that differ from the Windows environment compared against the traditional multi-user LAMP environment that Drupal is usually built against.
To explain what those directories are in the order you listed them:

The DevDesktop application code
Your sites you're managing with Acquia
Acquia application configurations
Drush application configurations

This data is separated mostly to accommodate a multi-user environment. So that...

All the data for the DevDesktop application is isolated so multiple users can use the app.
The sites you manage are separate from other users.
Your Acquia application configurations are separate from other users (e.g. your login info).
You Drush application configuration is separate from other users (e.g. your site aliases).
Comment: Thanks so much for your prompt and cogent replies. This helps my poor brain to understand how Drupal/Dev Desktop works.
Comment: No problem! The world of Drupal can be very obtuse at times, especially newbies. I'm glad to have helped.


Is there a 2/3 time signature, or "cut-time" equivalent for 3/4?

Question: Here's a passage written in 3/4 time:

(The composer uses an ambiguous shorthand after the first measure, but assume that where he wrote dotted-half tremolos he intended for the passage to be played 3 beats per measure with bow changes as spelled out in the first measure.)
Now suppose that along the way the composer wants to change the emphasis to two beats per measure, like this:

If this were a 4/4 ("common time") passage, something like this could be indicated with a change to 2/2 ("cut time").  But is there a time signature for this case of going from 3 quarter notes to 2 dotted-quarters?
My first guess was that the second example could be indicated with a time signature of 2/3.  But I can't find any examples of such a time signature, and would any musician understand that – especially if it weren't demonstrated explicitly in the first measure?
Comment: 6/8 should do what you're asking, if I'm understanding you correctly.
Answer: The lower number in time signatures basically is used for crotchets - 4, quavers - 8, and semiquavers -16. It reflects that a 'full bar' contains a semibreve, and the number tells how many of the notes will fill that bar.
So, even in compound time, the lower number will be 4,8 or 16. Having a 3 at the bottom wouldn't make sense. Cut time is really 4/4 with a 2/4 feel. Same bottom number.
The 3/4 in the top example does give a 1-2-3 feel, as it should. But the second example becomes 6/8, or 12/16 - a duple time sig., which often gets counted as a slow 1-2, 1-2. The time sig. exists already, and is quite appropriate.
Out of interest, check Bernstein's 'America' - where 3/4 gets morphed into 6/8, both conveniently having the same number of beats per bar, with the feel changing.
Comment: The second example should only become 12/16 if every 3rd 16th note is supposed to be emphasized (which I doubt given the beaming in the question).
Comment: @Dekkadeci - given only that sample, yes, 6/8 is more feasible.
Answer: 2/3 is not considered a valid time signature.  The top number is the number of beats in a bar.  The bottom number is the duration associated with 1 beat.  2/3 could be parsed as 2 half-note-triplets per bar, but that's ridiculous.  You'll only ever see powers of 2 (2, 4, 8, 16...) in the bottom position.
The time signature change you're showing in your examples is from 3/4 to 6/8. (While 6/8 has 6 8th notes per bar, it has 2 pulses per bar.)
This notation is a little unclear.  Have you seen this in an actual score, or is this just a theoretical question?  The top note, which follows the pulse in both examples, isn't really part of the tremolo, so I personally wouldn't notate it as such.  I'd notate the 2-note tremolo with stems down and actually write out 3 quarter notes (3/4) or 2 dotted quarter notes (6/8) above the tremolo with stems up.
This sort of change in pulse, where 3/4 can morph into 6/8 and vice versa, is called hemiola. If the change of pulse is only temporary, a change in time signature wouldn't be necessary since 3 quarters and 2 dotted quarters both make sense and mean the same thing in both time signatures.
Comment: @jjmusicnotes Yes, 2/3 is ridiculous. It is purposefully obtuse and hard to understand. The notation required to make it work would be very difficult to read. Whatever musical idea you think you're conveying, I guarantee you there is a conventional time signature which conveys the same idea and is easier to read. Sure, no rules and anything goes. I'm on board with wacky stuff like Nancarrow, Cage, Feldman, etc, but telling beginners that 2/3 is valid is only going to confuse them. By convention, 2/3 is invalid. You can't seriously be refuting this?
Comment: @jjmusicnotes - ridiculous - open to ridicule. When people do 'strange' things, that's what happens. It may be very clever - or it may just throw 'normal' into chaos. Still a valid word. Watered down - 'not normal'...
Comment: Is there a standard convention for a third note?  As mentioned sever times in several answers the bottom note represents the "type" of note that gets a beat.  Another way of looking at 4/4 it is 4 *(1/4) 4 quarter notes, 3/4 = 3 quarter notes, 3/2 = 3 half notes.  What is being challenged is the definition of a 1/3 note.  Someone mentioned half note triplet (if I'm correct) but that doesn't necessarily motivate a 1/3 note definition as the 1/2 note is being used to demarcate time intervals.  What would a 1/3 note be?
Comment: @jjmusicnotes  The composers you cite are essentially getting their rocks off to no good end.  Time signatures like that do nothing to change the rhythm of the piece.
Comment: @jjmusicnotes Nowhere did I say it was ridiculous because it is invalid. If there were any causality at all, I would presume it is the other way around. I describe it as invalid because a) most music software (that I have access to) won't even allow it, b) it has no defined meaning (how many pulses per bar? says who?), c) I have personally never seen it or anything like it used in real life. I describe it as ridiculous because it offers no functional meaning which cannot be conveyed using normal TSs. It would only ever be used to confuse, or perhaps out of confusion on the composer's part.
Comment: @ggcg I don't think the definition of a 1/3 note is in question. Math dictates it would be a half note triplet. The idea that a bar could be made up of only 2/3 of a triplet is ridiculous.
Comment: Not ridiculous. Thomas Adés uses time signatures like that all the time. Conlon Nancarrow used time signatures with square roots. Uncommon? Sure. Valid? Yes. A unit pulse can be divided by any number; most people just aren't used to "feeling" or dividing unit pulses by amounts other than powers of two.
Comment: @ibonyun: I suggest, that you replace your last comment by a more moderate version. Your assumption, who may have downvoted for which reason is just that - an assumption.
Comment: @Tim - today must be a day for semantics. Everything is "open" to ridicule, but ibonyun purports that 2/3 is invalid and therefore is "ridiculous". This is only true if 2/3 is invalid, which it isn't, which is why - using ibonyun's own logic - it wouldn't be ridiculous.
Comment: @ibonyun - people said similar things about the 2nd viennese school, dadaism, fluxism, expressionism, minimalism, etc. New ways of thinking make people uncomfortable, and they reject to make the world right. Clearly this makes you uncomfortable. I point things out when I see ideas need to be corrected for error. This is an erroneous thought that is well-intentioned. Really nothing personal. I won't be commenting on this further as you can't shout into deaf ears.
Comment: @jjmusicnotes Your objection seemed trivial to me, nitpicking about corner cases. I took that personally, which was probably evident from my comment. My apologies. I hope you can consider the meaning of my words with care, as words are all we have.
Comment: @jjmusicnotes FYI I am well versed and quite comfortable with all the movements you mentioned. That's my jam actually. Most music pre-1900 is boring IMO. But I'm also a pragmatist. 2/3 is not useful.
Answer: Since you mention bowing, presumably this is for strings and the part is played in double stops.
There is nothing ambiguous about the notation in your first example. It is absolutely clear: after the first bar, the top note is held for the whole of each bar. The slurs in the first bar are superfluous, but harmless.
If you want to assume the composer and/or editor and/or publisher didn't understand standard music notation, then of course you are entitled to that opinion. But you can't expect anyone else to guess what you think the notation should have been, unless you provide some evidence or context for your ideas.
The first bar of the second example is clear enough for any practical purpose. The following bars are identical to the first example and mean the same thing, of course.
2/3 is a perfectly acceptable time signature, though it doesn't mean anything that is relevant to your example. It means that one bar consists of two-thirds of a triplet of quarter notes. In some contexts, that sort of notation is clearer than a complex mess of tuplets that span bar lines, or tempo changes at every barline.
I don't understand why you think the relation between common time and cut time is relevant to the example either.
Comment: I wouldn't say that  2/3 is an "acceptable" time signature, as us musicians work exclusively with powers of 2 in the denominator. Otherwise, you're right on.
Comment: I see this sort of short-hand frequently in violin sheet music, usually with *segue* written after the illustration of how the short-hand should be played out.  My reference to common vs. cut time was by analogy: in both cases the notation is otherwise the same, but the beat emphasis is changed.
Comment: @feetwet I would expect *simile,* not *segue.*
Answer: Two things: I would assume that if there were a switch from 3/4 to 6/8, the 8th note would be consistent, and the pulse duration would change, but if one were wise, you'd simply indicate that with a little parenthetical marking above that says (in symbols I can't make here) 8th note = 8th note.
Best to err on the side of clarity and even redundancy.  You want your performers spending time on making music, not figuring out what you mean.  Also, 2/3 means something very specific, though many folks (as we've seen here) think it's not "valid." We call 8th notes 8th notes, or 1/4 notes 1/4 notes, because of how many of them there'd be in a whole note.
So 2/3 time would be a measure of 2 1/3 notes.  Now, what's a 1/3 note? Well, it'd be ONE note that lasts as long as one of the notes in a half note triplet.  So, 2/3 time would be launching into half note triplets, but only doing two of them.  These are called irrational time signatures, and they're great.
Normally, if we want regular 1/8 note triplets (which would be 12th notes, wouldn't they?) we have to have them in packs of three.  But what if you wanted 5 of them? You'd use the time signature of 5/12 time.  Not a big deal, but you find plenty of old-fashioned people (who still think poetry has to rhyme) who think that's not cool.
Answer: My understanding is cut time is a matter of changing common time (with 4 beats) to a feel with only two beats played at a faster tempo.
But you are talking about taking a triple meter with 3 beats and changing the pulse to 2 with no change in the total time. That's changing to compound meter. In other words you want two beats with subdivisions of 3.
If you want to alternate the meters, but keep the sixteenth subdivisions at the same speed, you could do like Berstein did in America list the meters together...
Answer: There is no single time signature for representing the change from 3 quarter-notes to two dotted-quarters in a measure (with the tempo per measure unchanged.) However it's common enough to have a name (and is known from some centuries.) The term "hemiola" has this change a one of its meanings. (Another meaning is a succession of 2-beat phrases in a 3-beat piece, typical in waltzes but usually just notated with half-notes and ties.)
There are two different time signatures that represent this grouping: 3/4 and 6/8. The first represents. Some composers (I think Leonard Bernstein in West Side Story) used alternating time signatures of 3/4 and 6/8. It's a bit "wordy" (or at least "signature heavy") but hard to misread. (So simple, even a computer can do it.)
I've seen three other methods. If the prevailing rhythm is 3/4 and only a few measures are 6/8 style, one could used dotting, beaming and slurring to make things clear. (It would be 3/4 beamed as 6/8.) A second method is the reverse if the piece is mostly 6/8. These are pretty easy to read. The other thing is to write something like 3/4+6/8 as the time signature and let the players figure it out. (Brahms wrote 3/4+2/4 to represent 7/4 in one piece.)
Personally I've found (not much experience) that most musicians can interpret a pair of dotted quarters (in a 3/4 measure) correctly. (Note that the 6/8 interpretation is dotted-quarter followed by eighth tied to quarter.)
Comment: True. That's why it's so interesting. I would have expected 3/4+2/4+2/4 or again, just write 7/4 beaming as 3+2+2.
Comment: Time signatures don't represent changes. They indicate two things: 1.) how many unit pulses there are in a given measure and 2.) what symbol represents a single unit pulse.
Comment: 3/4 +2/4 doesn't equal 7/4..!