text:
Q: Copy a selected range to another worksheet I am using code below which I am trying to change so as not to use .select
Selection.Select ' from active worksheet
    Selection.Copy
    Sheets("Purch Req").Select
    Range("A1").Select
    ActiveSheet.Paste

I have tried using this but there is no output to the other worksheet.
Dim src2Range As Range, dest2Range As Range

    Set src2Range = Selection 'source from selected range

    Set dest2Range = Sheets("Purch Req").Range("A1").Resize(src2Range.Rows.Count, src2Range.Columns.Count) ' destination range _
    'in Purch req worksheet

A: Here is good examples on How to avoid using Select in Excel VBA Link stackoverflow
Here is simples of
copy/paste - values = values - PasteSpecial method
Option Explicit
'// values between cell's
Sub PasteValues()

    Dim Rng1 As Range
    Dim Rng2 As Range

    Set Rng1 = Range("A1")
    Set Rng2 = Range("A2")
    Rng2.Value = Rng1.Value

    'or
    [A2].Value = [A1].Value

    'or
    Range("A2").Value = Range("A1").Value

    'or
    Set Rng1 = Range("A1:A3")
    Set Rng2 = Range("A1:A3")
    Rng2("B1:B3").Value = Rng1("A1:A3").Value

    'or
    [B1:B3].Value = [A1:A3].Value

    '// values between WorkSheets
    Dim xlWs1 As Worksheet
    Dim xlWs2 As Worksheet

    Set xlWs1 = Worksheets("Sheet1")
    Set Rng1 = xlWs1.Range("A1")

    Set xlWs2 = Worksheets("Sheet2")
    Set Rng2 = xlWs2.Range("A1")
    Rng2.Value = Rng1.Value

    'or
    Set Rng1 = [=Sheet1!A1]
    Set Rng2 = [=Sheet2!A1]
    Rng2.Value = Rng1.Value

    'or
    [=Sheet2!A1].Value = [=Sheet1!A1].Value

    'or
    Worksheets("Sheet2").Range("A2").Value = Worksheets("Sheet1").Range("A1").Value

    '// values between workbooks
    Dim xlBk1 As Workbook
    Dim xlBk2 As Workbook

    Set xlBk1 = Workbooks("Book1.xlsm")
    Set Rng1 = xlBk1.Worksheets("Sheet1").Range("A1")

    Set xlBk2 = Workbooks("Book2.xlsm")
    Set Rng2 = xlBk2.Worksheets("Sheet1").Range("A1")
    Rng2.Value = Rng1.Value

    'or
    Set Rng1 = Evaluate("[Book1.xlsm]Sheet1!A1")
    Set Rng2 = Evaluate("[Book2.xlsm]Sheet2!A1")
    Rng2.Value = Rng1.Value

    'or
    Evaluate("[Book2.xlsm]Sheet2!A1").Value = Evaluate("[Book1.xlsm]Sheet1!A1")

    'or
    Workbooks("Book2.xlsx").Worksheets("Sheet1").Range("A1").Value = _
        Workbooks("Book1.xlsx").Worksheets("Sheet1").Range("A1").Value

End Sub

Simple copy/paste
Sub CopyRange()
    Dim Rng1 As Range
    Dim Rng2 As Range

    Set Rng1 = Range("A1")
    Set Rng2 = Range("A2")
    Rng1.Copy Rng2

    [A1].Copy [A2]

    Range("A2").Copy Range("A1")

    '// Range.Copy to other worksheets
    Dim xlWs1 As Worksheet
    Dim xlWs2 As Worksheet

    Set xlWs1 = Worksheets("Sheet1")
    Set Rng1 = xlWs1.Range("A1")
    Set xlWs2 = Worksheets("Sheet2")
    Set Rng2 = xlWs2.Range("A1")
    Rng1.Copy Rng2

    Set Rng1 = [=Sheet1!A1]
    Set Rng2 = [=Sheet2!A1]
    Rng1.Copy Rng2

    [=Sheet1!A1].Copy [=Sheet2!A1]

    Worksheets("Sheet1").Range("A1").Copy Worksheets("Sheet2").Range("A1")

    ''// Range.Copy to other workbooks
    Dim xlBk1 As Workbook
    Dim xlBk2 As Workbook

    Set xlBk1 = Workbooks("Book1.xlsm")
    Set Rng1 = xlBk1.Worksheets("Sheet1").Range("A1")
    Set xlBk2 = Workbooks("Book2.xlsm")
    Set Rng2 = xlBk2.Worksheets("Sheet2").Range("A2")
    Rng1.Copy Rng2

    Evaluate("[Book1.xlsm]Sheet1!A1").Copy Evaluate("[Book2.xlsm]Sheet2!A2")

    Workbooks("Book1.xlsx").Worksheets("Sheet1").Range("A1").Copy _
    Workbooks("Book2.xlsx").Worksheets("Sheet1").Range("A1")

End Sub

PasteSpecial method
Sub PasteSpecial()

    'Copy and PasteSpecial a Range
    Range("A1").Copy
    Range("A3").PasteSpecial Paste:=xlPasteFormats

    'Copy and PasteSpecial a between worksheets
    Worksheets("Sheet1").Range("A2").Copy
    Worksheets("Sheet2").Range("A2").PasteSpecial Paste:=xlPasteFormulas

    'Copy and PasteSpecial between workbooks
    Workbooks("Book1.xlsx").Worksheets("Sheet1").Range("A1").Copy
    Workbooks("Book2.xlsx").Worksheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteFormats

    Application.CutCopyMode = False

End Sub

A: There is many ways to do that, but here goes two.
1)
Sub pasteExcel()
    Dim src2Range As Range
    Dim dest2Range As Range
    Dim r 'to store the last row
    Dim c 'to store the las column
    Set src2Range = Selection 'source from selected range

    r = Range("A1").End(xlDown).Row 'Get the last row from A1 to down
    c = Range("A1").End(xlToRight).Column 'Get the last Column from A1 to right
    Set dest2Range = Range(Cells(1, 1), Cells(r, c))
    dest2Range.PasteSpecial xlPasteAll
    Application.CutCopyMode = False 'Always use the sentence.
End Sub

2)
Sub pasteExcel2()
    Dim sht1 As Worksheet
    Dim sht2 As Worksheet 'not used!
    Dim src2Range As Range
    Dim dest2Range As Range
    Dim r 'to store the last row
    Dim c 'to store the las column

    Set sht1 = Sheets("Sheet1")
    Set sht2 = Sheets("Sheet2")

    sht1.Activate 'Just in case... but not necesary

    r = Range("A1").End(xlDown).Row 'Get the last row from A1 to down
    c = Range("A1").End(xlToRight).Column 'Get the last Column from A1 to right
    Set src2Range = Range(Cells(1, 1), Cells(r, c)) 'source from selected range
    Set dest2Range = Range(Cells(1, 1), Cells(r, c))
    sht2.Range(dest2Range.Address).Value = src2Range.Value 'the same range in the other sheet.
End Sub

Tell me if you need some improvement.


text:
Q: ERROR in calling UTL_MAIL procedures I am trying to send mails through UTL_MAIL.
where I used below code:
declare
v_sender VARCHAR2(30);
v_recipients VARCHAR2(60);
v_subj VARCHAR2(20);
v_msg VARCHAR2(200);
begin
v_sender := 'abc@xyz.com';
v_recipients := 'aaa@xyz.com';
v_subj := 'Info';
v_msg := 'This is an automated mail';
CALL (UTL_MAIL.SEND(v_sender, v_recipients, NULL, NULL, v_subj, v_msg));
END;

and I am receiving an error:

[Error] Execution (12: 9): ORA-06550: line 12, column 9:
  PLS-00222: no function with name 'SEND' exists in this scope
  ORA-06550: line 12, column 3:
  PL/SQL: Statement ignored

Please help me with this..
Thank you

redpajama_set_name: RedPajamaStackExchange


text:
Q: Change of measures with Wiener process I am trying to test importance sampling for a simple a Wiener process $W_t$ in R:
set.seed(123)
Z <- matrix(rnorm(12*1000),12,1000)
W <- apply(Z,2,cumsum) #Wiener process simulated 1000 times for 12 periods
B <- W-(1:12) #Brownian motion with drift -1
w <- exp(-W[12,]) #Radon-Nikodym derivative (actually w <- exp(-W[12,]-12/2))
mean(B[12,]) #-11.973
sum(W[12,]*(w/sum(w))) #-7.881 to compare with -12!

I think that the estimate with the derivative is not really "precise"! Any suggestions to improve the accuracy, besides increasing the number of simulations?


text:
Q: Alternar entre classes css com apenas 1 codigo Meu cenário é o seguinte, tenho 4 classes de animações e necessito que independente da minha escolha a div faça o seu papel, porem esta acontecendo de que se eu executar uma as outras  não funciona como deve.
a funcao toggle sempre mantem a opcao selecionada e a em branco, ha alguma maneira de verificar ou casar as classes para que somente elas troquem de classe? ex: flip in com flip out, lightspeedin com out , e assim vai.
no switch teria como sempre que eu clicar no botao ele verificar a classe ativa e colocar a contraria para ativar?
se este

function transicao1() {
  var element = document.getElementById("preview");
  element.classList.toggle("lightSpeedIn");
}

function transicao2() {
  var element = document.getElementById("preview");
  element.classList.toggle("lightSpeedOut");
}

function transicaoflip1() {
  var element = document.getElementById("preview");
  element.classList.toggle("flipInY");
}

function transicaoflip2() {
  var element = document.getElementById("preview");
  element.classList.toggle("flipOutY");
}
.lightSpeedIn {
  -webkit-animation-name: lightSpeedIn;
  animation-name: lightSpeedIn;
  -webkit-animation-timing-function: ease-out;
  animation-timing-function: ease-out;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes lightSpeedIn {
  0% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
  transform: translate3d(100%, 0, 0) skewX(-30deg);
  opacity: 0;
  }
  60% {
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: skewX(-5deg);
  transform: skewX(-5deg);
  opacity: 1;
  }
  100% {
  -webkit-transform: none;
  transform: none;
  opacity: 1;
  }
  }
  @keyframes lightSpeedIn {
  0% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
  transform: translate3d(100%, 0, 0) skewX(-30deg);
  opacity: 0;
  }
  60% {
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: skewX(-5deg);
  transform: skewX(-5deg);
  opacity: 1;
  }
  100% {
  -webkit-transform: none;
  transform: none;
  opacity: 1;
  }
  }

  .lightSpeedOut {
  -webkit-animation-name: lightSpeedOut;
  animation-name: lightSpeedOut;
  -webkit-animation-timing-function: ease-in;
  animation-timing-function: ease-in;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes lightSpeedOut {
  0% {
  opacity: 1;
  }
  100% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
  transform: translate3d(100%, 0, 0) skewX(30deg);
  opacity: 0;
  }
  }
  @keyframes lightSpeedOut {
  0% {
  opacity: 1;
  }
  100% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
  transform: translate3d(100%, 0, 0) skewX(30deg);
  opacity: 0;
  }
  }

.flipInY {
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  -webkit-animation-name: flipInY;
  animation-name: flipInY;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes flipInY {
  0% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  -webkit-transition-timing-function: ease-in;
  transition-timing-function: ease-in;
  opacity: 0;
  }
  40% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  -webkit-transition-timing-function: ease-in;
  transition-timing-function: ease-in;
  }
  60% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  100% {
  -webkit-transform: perspective(400px);
  transform: perspective(400px);
  }
  }
  @keyframes flipInY {
  0% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  -webkit-transition-timing-function: ease-in;
  transition-timing-function: ease-in;
  opacity: 0;
  }
  40% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  -webkit-transition-timing-function: ease-in;
  transition-timing-function: ease-in;
  }
  60% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  100% {
  -webkit-transform: perspective(400px);
  transform: perspective(400px);
  }
  }

  .flipOutY {
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  -webkit-animation-name: flipOutY;
  animation-name: flipOutY;
  -webkit-animation-duration: .75s;
  animation-duration: .75s;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes flipOutY {
  0% {
  -webkit-transform: perspective(400px);
  transform: perspective(400px);
  }
  30% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
  opacity: 1;
  }
  100% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  opacity: 0;
  }
  }
  @keyframes flipOutY {
  0% {
  -webkit-transform: perspective(400px);
  transform: perspective(400px);
  }

  30% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
  transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
  opacity: 1;
  }

  100% {
  -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  opacity: 0;
  }
  }
<button onClick="transicao1()"> APLICAR EFEITO DE ENTRADA</button>

<button onClick="transicao2()"> APLICAR EFEITO DE SAIDA </button>

 DIV A SER TRANSICIONADA

<button onClick="transicaoflip1()"> OUTRO EFEITO DE ENTRADA</button>

<button onClick="transicaoflip2()"> OUTRO EFEITO DE SAIDA </button>

A: Para ter certeza que você removeu os outros efeitos antes de aplicar os próximos, sugiro que você remova as classes de efeito.
Também, para simplificar a função, basta criar as classes que indicam efeito e direção (entrada e saída).
No exemplo abaixo, a função transicao recebe como parametros o nome do efeito e o direção.
A função simplesmente remove as classes de efeito e direção e acrescenta as que vieram da chamada:

function transicao(direction, effect) {
  //recebendo dois parametros apenas:
  // direction: 'in' OU 'out' - strings que representam se é de entrada ou saida
  // efecct 'ligthspeed' OU 'flip' - o tipo de efeito
  var element = document.getElementById("preview");
  element.classList.remove("in", "out", "ligthspeed", "flip"); //limpando tudo o que afeta
  element.classList.add(direction, effect); //acrescentando as escolhidas
}
/* sugiro mudar para classes independentes: .ligthspeed e .in e assim por diante*/
.ligthspeed.in { /* aqui a classe de efeito ligthspeed e de entrada */
  -webkit-animation-name: lightSpeedIn;
  animation-name: lightSpeedIn;
  -webkit-animation-timing-function: ease-out;
  animation-timing-function: ease-out;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@-webkit-keyframes lightSpeedIn {
  0% {
    -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
    transform: translate3d(100%, 0, 0) skewX(-30deg);
    opacity: 0;
  }
  60% {
    -webkit-transform: skewX(20deg);
    transform: skewX(20deg);
    opacity: 1;
  }
  80% {
    -webkit-transform: skewX(-5deg);
    transform: skewX(-5deg);
    opacity: 1;
  }
  100% {
    -webkit-transform: none;
    transform: none;
    opacity: 1;
  }
}

@keyframes lightSpeedIn {
  0% {
    -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
    transform: translate3d(100%, 0, 0) skewX(-30deg);
    opacity: 0;
  }
  60% {
    -webkit-transform: skewX(20deg);
    transform: skewX(20deg);
    opacity: 1;
  }
  80% {
    -webkit-transform: skewX(-5deg);
    transform: skewX(-5deg);
    opacity: 1;
  }
  100% {
    -webkit-transform: none;
    transform: none;
    opacity: 1;
  }
}

.ligthspeed.out {
  -webkit-animation-name: lightSpeedOut;
  animation-name: lightSpeedOut;
  -webkit-animation-timing-function: ease-in;
  animation-timing-function: ease-in;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@-webkit-keyframes lightSpeedOut {
  0% {
    opacity: 1;
  }
  100% {
    -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
    transform: translate3d(100%, 0, 0) skewX(30deg);
    opacity: 0;
  }
}

@keyframes lightSpeedOut {
  0% {
    opacity: 1;
  }
  100% {
    -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
    transform: translate3d(100%, 0, 0) skewX(30deg);
    opacity: 0;
  }
}

.flip.in {
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  -webkit-animation-name: flipInY;
  animation-name: flipInY;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@-webkit-keyframes flipInY {
  0% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    -webkit-transition-timing-function: ease-in;
    transition-timing-function: ease-in;
    opacity: 0;
  }
  40% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
    -webkit-transition-timing-function: ease-in;
    transition-timing-function: ease-in;
  }
  60% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    opacity: 1;
  }
  80% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  100% {
    -webkit-transform: perspective(400px);
    transform: perspective(400px);
  }
}

@keyframes flipInY {
  0% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    -webkit-transition-timing-function: ease-in;
    transition-timing-function: ease-in;
    opacity: 0;
  }
  40% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
    -webkit-transition-timing-function: ease-in;
    transition-timing-function: ease-in;
  }
  60% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    opacity: 1;
  }
  80% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  100% {
    -webkit-transform: perspective(400px);
    transform: perspective(400px);
  }
}

.flip.out {
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  -webkit-animation-name: flipOutY;
  animation-name: flipOutY;
  -webkit-animation-duration: .75s;
  animation-duration: .75s;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@-webkit-keyframes flipOutY {
  0% {
    -webkit-transform: perspective(400px);
    transform: perspective(400px);
  }
  30% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
    opacity: 1;
  }
  100% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    opacity: 0;
  }
}

@keyframes flipOutY {
  0% {
    -webkit-transform: perspective(400px);
    transform: perspective(400px);
  }
  30% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
    transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
    opacity: 1;
  }
  100% {
    -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    opacity: 0;
  }
}
<button onClick="transicao('in','ligthspeed')"> APLICAR EFEITO DE ENTRADA</button>

<button onClick="transicao('out','ligthspeed')"> APLICAR EFEITO DE SAIDA </button>

 DIV A SER TRANSICIONADA

<button onClick="transicao('in', 'flip')"> OUTRO EFEITO DE ENTRADA</button>

<button onClick="transicao('out', 'flip')"> OUTRO EFEITO DE SAIDA </button>

A: estudando alternativas acabei encontrando uma maneira mais direta apenas utilizando o comparativo if e else

        function transicao_lightspeed(item){
           if(item.className == "lightSpeedIn") {
              item.className="lightSpeedOut";
           } else {
              item.className="lightSpeedIn";
           }
        }
.lightSpeedIn {
  -webkit-animation-name: lightSpeedIn;
  animation-name: lightSpeedIn;
  -webkit-animation-timing-function: ease-out;
  animation-timing-function: ease-out;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes lightSpeedIn {
  0% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
  transform: translate3d(100%, 0, 0) skewX(-30deg);
  opacity: 0;
  }
  60% {
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: skewX(-5deg);
  transform: skewX(-5deg);
  opacity: 1;
  }
  100% {
  -webkit-transform: none;
  transform: none;
  opacity: 1;
  }
  }
  @keyframes lightSpeedIn {
  0% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(-30deg);
  transform: translate3d(100%, 0, 0) skewX(-30deg);
  opacity: 0;
  }
  60% {
  -webkit-transform: skewX(20deg);
  transform: skewX(20deg);
  opacity: 1;
  }
  80% {
  -webkit-transform: skewX(-5deg);
  transform: skewX(-5deg);
  opacity: 1;
  }
  100% {
  -webkit-transform: none;
  transform: none;
  opacity: 1;
  }
  }

  .lightSpeedOut {
  -webkit-animation-name: lightSpeedOut;
  animation-name: lightSpeedOut;
  -webkit-animation-timing-function: ease-in;
  animation-timing-function: ease-in;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  }
  @-webkit-keyframes lightSpeedOut {
  0% {
  opacity: 1;
  }
  100% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
  transform: translate3d(100%, 0, 0) skewX(30deg);
  opacity: 0;
  }
  }
  @keyframes lightSpeedOut {
  0% {
  opacity: 1;
  }
  100% {
  -webkit-transform: translate3d(100%, 0, 0) skewX(30deg);
  transform: translate3d(100%, 0, 0) skewX(30deg);
  opacity: 0;
  }
  }
<input type="button" value="Velocidade" class="" onclick="transicao_lightspeed(preview)" />

Seu
        Texto


text:
Q: reset main class     package
    {
        public class Main extends Sprite {
        private var a=0;
        private var b=0;
        private var c=2;

        public function Main(){
            a=9;
            b=4;
            c=8;
        }
    }
}

Is there an easy way to reset all of my variables to the way they were when I first loaded the package so that I don't have to go through all of the variables and reset them manually?
Thank you.

A: You could save the variables when the class is initialised, and then load them back which would effectively be a reset. Try this:
package
{
    import flash.display.Sprite;

    public class Main extends Sprite
    {
        private var _saved:Array = [];

        public var awesome:Boolean = true;
        public var val:String = "hello";

        public function Main()
        {
            saveVars("awesome","val","alpha");

            awesome = false;
            alpha = 0.5;
            val = "there";

            loadVars();

            trace(alpha); // 1
            trace(val) ;// hello
            trace(awesome); // true
        }

        /**
         * Saves defined vars
         * @param ...args A list of variables to save
         */
        public function saveVars(...args):void
        {
            _saved = [];

            var i:String;
            for each(i in args)
            {
                _saved[i] = this[i];
            }
        }

        /**
         * Loads from last save
         */
        public function loadVars():void
        {
            var i:String;
            for(i in _saved)
            {
                this[i] = _saved[i];
            }
        }
    }
}

This has obviously the advantage of being able to save your variables at any point throughout the application runtime.

A: The short answer is no.  However, one solution might be to assign your class variables to new variables that you declare within your function.  That would preserve the initial values and makes them available to other functions.  A true "reset" would only happen if the class were re-instantiated.

A: late ?
Why not creating a new class loaded by the "Import" and "AddChild" syntaxes where you put your variables you remove and load again ?


text:
Q: is sharing temp tables across procedures considered bad form? I have 2 procedures. One that builds a temp table and another (or several others) that use a temp table that's created in the first proc. Is this considered bad form? I'm walking into an existing codebase here and it uses this pattern a lot. It certainly bothers me but I can't say that it's explicitly a bad idea. I just find it to be an annoying pattern -- something smells rotten but I can't say what. I'd prefer to build the table locally and then fill it with an exec. But that requires procs that only return one table, which is unusual in the existing codebase.
Do the gurus of SQL shy away from this sort of temp table sharing? If so, why? I'm trying to form a considered opinion about this and would like some input.
Would a view be a viable alternative?
What about performance? Would it be better to build a @table locally or build a #table in the "fill" proc?
There's a good discussion of all methods here: http://www.sommarskog.se/share_data.html

A: As a programming paradigm it is ugly because it involves passing out-of-band parameters ('context parameters') that are not explicitly called out in the procedure signatures. This creates hidden dependencies and leads to spaghetti effect.
But in the specific context of SQL, there is simply no alternative. SQL works with data sets and you cannot pass back and forth these data sets as procedure parameters. You have few alternatives:

*

*Pass through the client. All too obvious not a real option.

*XML or strings with delimiters types to represent results. Not a serious option by any stretch, they may give good 'programming' semantics (ie. Demeter Law conformance) but they really really suck when performance comes into play.

*shared tables (be it in tempdb or in appdb) like Raj suggest. You're loosing the #temp automated maintenance (cleanup on ref count goes to 0) and you have to be prepared for creation race conditions. Also they can grow large for no reason (they're no longer partitioned by session into separate rowsets, like #temp tables are).

*@tables. They're scoped to the declaration context (ie. the procedure) and cannot be passed back and forth between procedures. I also discovered some nasty problems under memory pressure.

A: The biggest problem with sharing temp tables is that it introduces external dependencies into a procedure that may not be apparent at first glance. Say you have some procedure p1 that calls a procedure p2 and a temp table #t1 is used to pass information between the two procedures. If you want run p2 in isolation to see what it does, you have to create a "harness" that defines the #t1 before you can run it. Using temp tables in T-SQL is often equivalent to using global variables in other languages-- not recommended but sometimes unavoidable.
SQL Server 2008 now has table-valued parameters but Microsoft chose to make them read-only in this release. Still, it means you don't have to use temp tables in some scenarios where you had to before.
My advice is, use them if you have to, but document their use thoroughly. If you have some proc that depends on a temp table to run, call this out in a comment.

A: Sometimes this is the only way to go.  If you need to do this, then DOCUMENT, DOCUMENT, DOCUMENT the facts.  Here is one way to make it clear, put the table definition as a comment in the parameter section...
CREATE PROCEDURE xyz
(
     @param1  int            --REQUIRED, what it does
    ,@param2  char(1)        --OPTIONAL, what it does
    ,@param3  varchar(25)    --OPTIONAL, what it does
    --this temp table is required and must be created in the calling procedure
    --#TempXyz (RowID      int          not null primary key
    --         ,DataValue  varchar(10)  not null
    --         ,DateValue  datetime     null
    --         )
)

Also document in the calling procedure where the temp table is created....
--** THIS TEMP TABLE IS PASSED BETWEEN STORED PROCEDURES **
--** ALL CHANGES MUST TAKE THIS INTO CONSIDERATION!!!    **
CREATE TABLE #TempXyz
(RowID      int          not null primary key
,DataValue  varchar(10)  not null
,DateValue  datetime     null
)

A: I've encountered this same exact problem. What I can say from personal experience:
If there's a way to avoid using a #temp table across multiple procedures, use it. #temp tables are easy to lose track of and can easily grow tempdb if you're not careful.
In some cases, this method is un-avoidable (my classic example is certain reporting functionality that builds data differently based on report configration). If managed carefully, I believe that in these situations it is acceptable.

A: Sharing the temp tables is not a bad idea. But we need to ensure that the table level data should not be manipulated by the two procs at the same time, leading to Dirty Read/Write scenario. This will also help to have a single table [centralized ] and the procs working on it, to have sync-up data.
Regarding performance, it is true that, having multiple procs sharing the same temp data, will decrease performance. But at the same time, having individual tables [ per Proc ] will lead to increased memory consumption,

A: I have used this approach in a few cases. But I always declare the temp table as a fully qualified table and not by using #tablename.
CREATE TABLE [tempdb].[dbo].[tablename]

with this approach, it is easy to keep track of the temp table.
Raj

A: Another technique I've seen to avoid using temp tables is so-called "SPID-keyed" tables. Instead of a temp table, you define a regular table with the following properties:
CREATE TABLE spid_table
(
   id INT IDENTITY(1, 1) NOT NULL,
   -- Your columns here
   spid INT NOT NULL DEFAULT @@SPID,
   PRIMARY KEY (id)
);

In your procedures, you would have code like the following:
SELECT @var = some_value
FROM spid_table
WHERE -- some condition
AND spid = @@SPID;

and at the end of processing:
DELETE FROM spid_table
WHERE spid = @@SPID;

The big disadvantage of this is that the table uses the same recovery model as the rest of the database so all these transient inserts, updates and deletes are being logged. The only real advantage is the dependency is more apparent than using a temp table.

A: I guess, it is OK if the 2nd proc checks for existence of temp table & moves forward, if so. Also, it can raise error, if the temp table doesn't exist, asking user to run the proc1 first.
Why is the work divided in 2 stored procs? Can't things be done in 1 proc?


text:
Q: FabricJs clip only drawing not images I use this code to clip canvas in FabricJS:
var mask='<svg width="760" height="406" xmlns="http://www.w3.org/2000/svg"  xmlns:svg="http://www.w3.org/2000/svg"><g><ellipse fill="#c2c2C2" stroke-width="0" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" cx="380.00004" cy="203.00001" id="svg_1" rx="375.11113" ry="198.22223" stroke="null"/></g></svg>';
var canvas=new fabric.Canvas("canvas");
fabric.loadSVGFromString(mask, function(objects, options) {
var loadedObject = fabric.util.groupSVGElements(objects, options);
loadedObject.set({left:0,top:0});
canvas.clipTo = function(ctx) {
    loadedObject.render(ctx);
};
canvas.renderAll();
});

JsFiddle
I want only drawings to be clipped not the ribbon image.
Thank you


text:
Q: Is there a way to enable parallax for a Form Sheet on iPad? thanks for turning up :-)
I noticed that on the iPad the Form Sheet view does not have any iOS 7 parallax effects, and I would actually like to incorporate this because I think it kinda looks cool.

Well this is what I have and it doesn't have that, so is there a way to do this? How would one go about doing it? I've googled and googled and google has finally failed me because nothing appropriate is appearing.
Thanks :)

A: This can be done with some effort.
First off, you need to know how to add parallax to a view in general:
I have the following category method for UIView to make it easy:
- (void)addDepthMotionX:(CGFloat)x y:(CGFloat)y {
    Class clazz = NSClassFromString(@"UIInterpolatingMotionEffect");
    if (clazz) {
        BOOL reverse = NO;
        if (CGAffineTransformEqualToTransform(self.transform, CGAffineTransformMakeRotation(-M_PI_2)) || CGAffineTransformEqualToTransform(self.transform, CGAffineTransformMakeRotation(M_PI_2))) {
            reverse = YES;
        }

        UIInterpolatingMotionEffect *eff = [[clazz alloc] initWithKeyPath:@"center.x" type:reverse ? UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis : UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
        eff.maximumRelativeValue = @(x);
        eff.minimumRelativeValue = @(-x);
        [self addMotionEffect:eff];
        eff = [[clazz alloc] initWithKeyPath:@"center.y" type:reverse ? UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis : UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
        eff.maximumRelativeValue = @(y);
        eff.minimumRelativeValue = @(-y);
        [self addMotionEffect:eff];
    }
}

The code is guarded so it won't crash if called from other than iOS 7 (or later).
Now to add parallax to a view you simply do:
[someView addDepthMotionX:10 y:10]; // pick an appropriate depth value

The final step to your question is to apply this to the root of the view controller you are displaying.
Here's code you can add in the viewWillAppear: method of the view controller. Adjust to meet your needs:
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if (self.isBeingPresented || self.isMovingToParentViewController) {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && self.modalPresentationStyle == UIModalPresentationFormSheet) {
            [self.navigationController.view.superview addDepthMotionX:15 y:15];
        }
    }
}

One issue with this code is if the user rotates the iPad 90 degrees after the form sheet is presented, the parallax effect needs to be updated. But this will get you started.


text:
Q: How to detect when Chrome's "click-to-play" Flash blocking feature is currently active Tracking state of Chrome's Click-to-play feature
How do you detect that a Flash plugin has been temporarily disabled, or, conversely, detect that it has been enabled due to Chrome's "click-to-play" feature?
Background
Chrome's new "click-to-play" feature detects plugins that are not visibly significant and pauses them. Chrome displays a "play" button over the plugin, a user may click the "play" button to activate the plugin. (reference: https://productforums.google.com/forum/#!topic/chrome/xPcpRBzyPcc)
Here's a screenshot of it in action (notice white play buttons):
You can see in this screen shot that it has paused a video-player (right column). That video player has HTML5-based controls overlaying a Flash-based video player. So, there's no way for a user to click the play-button as the entire SWF is purposefully covered by HTML5-based play/pause controls.
What I need is to detect when the SWF has been paused by the "click-to-play" feature so I can disable the controls and make the SWF interactive.
What I've tried

*

*In JavaScript - All methods exposed via ExternalInterface are still available though the SWF is paused. It actually responds like it's playing and does not return an error.

*In JavaScript - Update the size of the embedded <object> to > 700x400px. "Click-to-play" does not pause a SWF of this size. So, I tried using -webkit-transfor: scale(0.5) to use CSS to scale it back to desired size. Chrome calculates the final rendered size and pauses the SWF regardless.

*In Flash - stage.frameRate returns correct value (it's not set to 0 to pause the SWF for instance)

In writing up this question I found an answer, decided to post here anyways in case others need help with this issue.

A: For the benefit of others who are looking for the rules around Flash blocking stuff,please see them below:

*

*The Flash Content and the page are loaded from the same domain.
Unknown Width and Height of the Flash Object ie when Chrome gets the
width and height as 0 or less than 0.

*The Flash Content is
whitelisted by the user in Chrome Settings.

*The Width and Height of
the Flash Object are less than or equal to 5 each, considering the
content to be Tiny and essential.

*The Width and Height of the
Flash object are equal or greater than 398x298.

*The Aspect Ratio
of the content is 16:9, (with an allowed deviation of 0.01) AND  the
width*height area is at least 120K.

At least one of the above criterias need to be met, in order to get the content marked as Essential and not get Auto-Paused. Although, I have seen few deviations and Chrome hasn't made any public announcement on the rules yet.

A: To circumvent the Chrome click-to-play throttling, load your SWF from the same domain and protocol as your site.

You can use the AS3 ThrottleEvent to detect when the SWF has been throttled.
// AS3 code
import flash.events.ThrottleEvent;
import flash.external.ExternalInterface;

stage.addEventListener(ThrottleEvent.THROTTLE, onThrottleEvent);

private function onThrottleEvent(e:ThrottleEvent) {
    ExternalInterface.call("onThrottleEvent", e.state); // call javascript function
}

You can setup an ExternalInterface call to keep track of this state in JavaScript, in JavaScript manage z-index of your SWF based on if it's throttled or not.
// JS Code
var IS_THROTTLED = false;

window.onThrottleEvent = function (throttleState) {
  IS_THROTTLED = (throttleState === "throttle");
}

A: Add an empty Flash file larger than 398x298 at the bottom of your page. I found once you have at least one Flash file above their minimum Chrome will not pause any of your Flash. You cannot hide this extra Flash file with CSS. Optionally use a javascript timeout (3 seconds) to hide the empty Flash file in case it messes with your page layout. I'm using swfObject for embedding.


text:
Q: Only RSA, generated on Android is working properly under Android (5.0+ devices) I've tried to use RSA. I wanted to check, if all is correct, so I used encryption and decryption (only for testing).
It seems, that only the private key, that was generated under android is working properly.
I'm getting the following error for RSA keys, that were generated via openssl:
 java.security.spec.InvalidKeySpecException: java.lang.RuntimeException:
 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag

For public keys all is working for androidgenerated and opensslgenerated keys.
final String RSA_ENCODED_PRIVATE_KEY_ANDROID_GENERATED = "" +
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD8z7AfzAPlOrKUEOH0fewwLHUq" +
"F+kEhETFTYr+5p0IanXKBZPI+hbvk5zKaZkX6FhyiIdwCmyELsQk2L43xkW6YXzg9bL4xSx06VcA" +
"iWDk4onU3K9pVC51Tq1Z+ygg3zvSSoRaUxW3aNHDygx8oIIJpuOQ7x+2TF8sFq1GIy2YdH/Eih02" +
"s2/w3ExykxBn+5rWgj0ZpoWO34umRfQooYeThbJx94v2ap7lOOPPZFiKvH7mUDbOJfb3xcGPynJE" +
"45oDNaew/yOeAjCS/ISHJcZjF8ip7/YKsMRQXCQxzCyUSSEH9ifj90K46H2vx46E7JHBMQk0IuyL" +
"jqL8V3dYhmibAgMBAAECggEAJ9wjG9BR6OmJUHkc9yyHecz4qCte7Pxhz237dVcs+S+35KNeerib" +
"tyhh9zQRFEjo8R3/pLWwCGNLP7gAvdCAG/PU+a8jib+k08YalpYSdeQV8T7eVVAVhx9hi6di21P3" +
"HZ/sIEWrTeCz+he4QkoYVqc+iBJ7wIVoGA53QXC4dqnPZmPcQgaNOAgfz+FTB6ybPduZhL21Qgtq" +
"1IlJ+N5j8mykILj5J1FqCDq5PJA4BwL7f/QK7xRZ8BJGE/6LCmNjXym6C/Dc+uTpIkFiDE2LfgDG" +
"EWVoSnr5kRdt0ucCGPLyCjQ+SrAFtypE6MzL2rC4kfBR1KdXuZB37P+Mlabr0QKBgQD+3yn+Nx4Q" +
"Op8VafH1ntL0vWrQhHoXicisJdWL3dbXELRmEPzOrrlsfhzU5SVLlXBD/eW+aOM745vbQZ9eeBhE" +
"us/QE0ofHPaqy68YFI8IgXSWPGWWimWwNVxZnllAV/8KMU4wRWpcxs7TIbKpRL4EMBk6L610Zq83" +
"1XxqOzqJCQKBgQD97jBdFls+5TQ5u+ws0m8DCtM1kuN+AYFI5UuN6+UBTo1zY/MvolrF5aqTxrUp" +
"xAt6+kPl/0FExIgXJ61kl8o5ZbRGUaZtVUUytDAoJpbYjOzZ7WrRRUwkh5aMmwJraBctR+udkF8N" +
"8+JqiOLbzKRNVWmrw2U7eO3zB/MRi09BgwKBgBpQE9fI/POT+cSOMYq4IPNfct2gL7KqaOtM5KUR" +
"/BIsCVPYQSFdbItE4dkg5x7MiNCcL9HepkcSko6qUbfBElBWMQo8U5SuutCbQrJrvPCV3OF9zsch" +
"9qmgeK5P6Mr5yrzUpkvZfsehRs0JV5aeIDfyd0hIj9HKoCBVjAizoLFxAoGBANLNV+0PUDSIhrCf" +
"J1OWZn46EFjbVmwWx8NCR1TMTlKlaZwvj4Ut3PmIzfDb9y1zCKzQ8mkPXJnAJdJDKBjoQgMgQWZX" +
"Bjihn06Wc5wBXRzs8PuBszmDs9Bnlz2muX187jCzEhC994tXudEDToF2A7gHfjAPiAy1OaSWJt2b" +
"rvINAoGBAP6FnMeqrLEmU14vfPOWBSsPeEPI3kCOUhvMo29SnLx5gdE/gocq5AMEydNt0zIWwLAu" +
"qiO74DIJmK+b10czQg4+sJhk4iQ1cK/k0QQ4wrpu3JDgpgKPFeiyTgPyUHh1O57RCXS2feZAAU2o" +
"napBWm7pfLOyAgoB2Im88GMFTnMY";

final String RSA_ENCODED_PRIVATE_KEY_OPENSSL_GENERATED = "" +
"MIIEpQIBAAKCAQEA+cNkMcWTXY5ZXxwwg0AkrZ5jVyoTTBbYqHWRghrOnpddES48" +
"COot9/oeKElu17Q+AfWTTsWTlR8pQdnVsT1fBQJrZSY/YCsNbKv4BfKnurxOQyck" +
"Tz5ysIitWqJCpiPvRB957jWMIMMPcB/VmI0q6wZ+f7BaTl89QKSR8nWQDgkOdQc7" +
"D/aSUdWckak6ILvZAcjhzR0OL6O6TaeKgHT1g7slexO3haMKbaW8dc1Vgq/D7cAi" +
"EBTGxNQLhEL8LPUnSYeQqzdKqj5xP7AUnT/0EAEX5Oz3zNzZozNDNhcbZXx+xike" +
"s60y+6MPW2ihKBt1G/BwUBj3VpAjdlq1y/2lKQIDAQABAoIBAQDkWGQpMPaLCVLi" +
"JrafuKwP44f1L+2WmiiY02wl4/ZVfhNDWt7eU6OVXKHnuUNSiGJMjkWQNgi4xFWG" +
"8+5v7akKvmyLfI1ikdnjKdJHNdNtYS24LXf/zxsyFLNQ8po2pRHiWVizlVc4uL1L" +
"iH9SynWbjENo4EWf82jfydX5MsxyVrz1qmh5JeQC4VgxFdpz8Q912gfAc+h9QK8e" +
"x6MVP/LoIeDBuQf4+1kmTN3Szyc+y0i1Bfem8NrswlTobBXwV4CcnvX+kArDlOTG" +
"H6+j5murcZe2A/un/mUSC/3hCC84wEkr8uJsZ0JkNRqBga55Rema7AcFIZ04AZvl" +
"gEroQboBAoGBAP6svxtfmBArLNZe+Opm8ena7RG5b9WHFMnrND7in/2GTHQlfteq" +
"csFAKxnuq9BiBlY3Qm65o8etm7GdSRlUwiBy2r8P1RfV6LGRFK/Jzgk9gDh+yJpg" +
"rEEQ6c0n0FJtOloNehP7sYIOSSPqztyFH7QGkTMxqUT+GOfQsal+RnlBAoGBAPsQ" +
"GiinmsSlZ1xaA2knGKIiez7ms1/Dv5BIpjme9JkR7uIg+5WPcFBqufMdQ98OmFlT" +
"u1aPHW3/+eis/R1Y24h30TBH4DvhXz7D+OIUDOTfBEQ83bGSNP4AInhNlCfzDV1Y" +
"SjdMKoGyMxd7tWPxtDkoC3VBbz8dpEMZF3z4FgnpAoGBANC2J6Q6UneluogwqxQG" +
"q+j4FuM4spMusfXMwTNsLKvr/QoOlIYQVR1VBj2pYLtVKlZL0TDHCJcjCv6jpP2S" +
"fclz9xsv0XZIQvwKpwZtf2IJOeSS2rnR0jk8sC8Gmu6CP5j/hHWOBupL5Nr/muoU" +
"W2gBHcvzvgIhr62DVaZPK1hBAoGBAOqsq3by66UCYvIdJXEF3W24Q3GRXXuXUpmA" +
"fvf/T+1AqQVwBRpQoJBaooPQCCAY2Wkt7j/DuKOYkLXf9RyYcWRHcx7pIH14dXoK" +
"3rocOc05dRh/uE4CN0xxPccr5N/OveBR5dV4eYcP1dgOh4frZyXB+6vXxS+++krJ" +
"yn3Cu375AoGASxHCB0gdfYRyWQEl0WoL1eyohdAJf08kVBZtAQ2jLeqY0ZEdUpzG" +
"+99qyw2IysGMwmjCxribLwbUm2cg74lZnX0NQH4HfQ5Pp4c0RUyJARrVzPhyQ1lu" +
"vgPZpCebTX9/118crlHQlTiGD4M258ghR8msm/+p4Efl8NvEcQ35y04=";

byte[] keyBytes = Base64.decode(RSA_ENCODED_PRIVATE_KEY_ANDROID_GENERATED, Base64.DEFAULT);
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PrivateKey key = keyFactory.generatePrivate(spec);//working

byte[] keyBytesOpenSSL = Base64.decode(RSA_ENCODED_PRIVATE_KEY_OPENSSL_GENERATED, Base64.DEFAULT);
PKCS8EncodedKeySpec specOpenSSL = new PKCS8EncodedKeySpec(keyBytesOpenSSL);
KeyFactory keyFactoryOpenSSL = KeyFactory.getInstance("RSA");
PrivateKey keyOpenSSL = keyFactoryOpenSSL.generatePrivate(specOpenSSLenter code here);//java.security.spec.InvalidKeySpecException

A: The structure of the OPENSSL version is different from the ANDROID one.
See both data structures in the online ASN.1 decoder:
RSA_ENCODED_PRIVATE_KEY_ANDROID_GENERATED
RSA_ENCODED_PRIVATE_KEY_OPENSSL_GENERATED
Therefore I assume that the OPENSSL version is not a valid PKCS#8 structure, only a subset containing the PrivateKey structure.
May be you executed the wrong command using OpenSSL, if I read the documentation correct it creates by default a PKCS#1 structure. If you want a PKCS#8 strcusture you have to convert it later using openssl pkcs8 .. command.


text:
Q: Array of files and value assigning I have 2 questions.
I want to create an array of files in C. But I'm not sure whether I have to malloc the size before or not.Can I just use FILE** files as an array or do I have to malloc them before. And if I have to make space, do I need to reserve 4 bytes (x86)?
I have the variable "char extra[8] = { 0xAE00AF00B000B100 };" and I want to assign it to the end of another char array[24]. Is there a faster way of doing that without having to type in every value by hand or using a for loop.
char extra[8] = { 0xAE00AF00B000B100 };
// index is a random place in the string
name[index] = '\0';
i = 0;
if (index > 16) {
    for (i = 24-index; i < 8; i++) {
        index++;
        name[index] = extra[i];
        }
    }
else {
    name[17] = 0xAE;
    name[18] = 0x00;
    name[19] = 0xAF;
    name[20] = 0x00;
    name[21] = 0xB0;
    name[22] = 0x00;
    name[23] = 0xB1;
    name[24] = 0x00;
}

I need to add those extra bytes btw.

A:
I want to create an array of files in C. But I'm not sure whether I
  have to malloc the size before or not.Can I just use FILE** files as
  an array or do I have to malloc them before. And if I have to make
  space, do I need to reserve 4 bytes (x86)?

If you need to have an array of files, it is possible to use an array of pointers as follow:
#include <stdio.h>

FILE *array[NB_FILES];

Or you can do it dynamically if NB_FILES is only known at runtime.
#include <stdio.h>
#include <stdlib.h>

FILE **array = malloc(nb_files * sizeof *array);

I have the variable "char extra[8] = { 0xAE00AF00B000B100 };" and I want to assign it to the end of another char array[24]. Is there a faster way of doing that without having to type in every value by hand or using a for loop.

The standard C library provides the function memcpy, which is a builtin on many compiler (so it will be faster than a for loop).
#include <string.h>

char array[24];
char extra[8];

memcpy(array + sizeof array - sizeof extra - 1, extra, sizeof extra);


text:
Q: Unable to load class [com.sun.jmx.mbeanserver.RepositorySupport] to check against the @HandlesTypes after migrating to tomcat 7.0.22
and installing t7mp (tomcat 7 plugin from google code) i am running on maven 2 btw
when trying to run mvn t7:run, i got the following exception:
WARNING: Unable to load class [com.sun.jmx.mbeanserver.MBeanInstantiatorImpl] to check against the @HandlesTypes annotation of one or more ServletContentInitializers.
java.lang.IncompatibleClassChangeError: Implementing class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
        at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2006)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1969)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1858)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1826)
        at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1812)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1306)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1055)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:978)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1329)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:389)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:334)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:621)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at com.googlecode.t7mp.RunMojo.execute(RunMojo.java:52)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Oct 18, 2011 11:50:00 AM org.apache.catalina.startup.ContextConfig checkHandlesTypes

here's my configuration for t7mp:
<plugin>
                <groupId>com.googlecode.t7mp</groupId>
                <artifactId>maven-t7-plugin</artifactId>
                <version>0.9.6</version>
                <configuration>
                     <tomcatHttpPort>8081</tomcatHttpPort>
                     <tomcatShutdownPort>8008</tomcatShutdownPort>
                     <tomcatVersion>7.0.22</tomcatVersion>
                </configuration>
</plugin>

so any ideas why i am getting this error, and how to solve it ?
UPDATE:
i got the same error when trying to run my external tomcat7 from eclipse.

A: well above exception was gone by excluding jmxtools,*jmxri* from the log4j library
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.15</version>
  <exclusions>
    <exclusion>
     <groupId>com.sun.jdmk</groupId>
     <artifactId>jmxtools</artifactId>
    </exclusion>
     <exclusion>
      <groupId>com.sun.jmx</groupId>
       <artifactId>jmxri</artifactId>
     </exclusion>
  </exclusions>
</dependency>


text:
Q: The import com.interwoven cannot be resolved I am new to Teamsite and a not sure which jar file to use for resolving the issue that I get while trying to write a Java Datasource in Eclipse.
The list of imports I am using are:
import com.interwoven.datasource.MapDataSource;
import com.interwoven.datasource.core.DataSourceContext;
import com.interwoven.livesite.dom4j.Dom4jUtils;
import com.interwoven.serverutils100.InstalledLocations;
import com.interwoven.cssdk.filesys.CSVPath;

All these imports show the same error

The import com.interwoven cannot be resolved.

Can anyone please tell me which jar files should I add?


text:
Q: XSS_CLEAN doesn't work in CodeIgniter $this->input->post('question', TRUE)
If even I add TRUE, it still allows people to add html code. Why is that?

A: The xss_clean() function does not remove all HTML, it removes/replaces specific things that are considered dangerous, like <script> tags.

http://codeigniter.com/user_guide/libraries/security.html
The XSS filter looks for commonly used techniques to trigger Javascript or other types of code that attempt to hijack cookies or do other malicious things. If anything disallowed is encountered it is rendered safe by converting the data to character entities.

Someone injecting a <p> tag into your page, while maybe not desired, is not really an effective attack. You'll have to specify what you want to do with it. In many cases, you will want HTML output that has been xss_clean()ed.
It sounds like you want either htmlspecialchars() or strip_tags() (note: these two very different things). If you want to encode the HTML, you can also use CI's html_escape():
echo html_escape($this->input->post('question'));

If you want HTML output and not entities, just use the XSS filter by itself:
echo $this->input->post('question', TRUE);
echo xss_clean($user_input);


text:
Q: Defold timer.delay function parameter I am confused as to how to use the timer.delay function. I know the first parameter is the number of seconds of delay; the second is whether it should be repeated; the third is a callback function used after the timer has run down. By my understanding a callback is another function as a parameter. The page on the defold website, though, gives a function with arguments already inserted
      callback function(self, handle, time_elapsed) timer callback function

I am trying to use the timer.delay function like
timer.delay(5, false, pr(self, "handle", "2"))

with
function pr()
    print("Function activated")

A: The callback parameter is a function that will be called. When this function is called when your timer triggers. It will be called with 3 arguments which you can use in your callback function, if needed.
the function(self, handle, time_elapsed) in the documentation tells you how your callback function will be called. The first argument is self, the second is the timer handle and the third is the elapsed time.
You could do someting like this:
local function myCallback(obj, handle, elapsed)
  print("Timer with handle " .. handle .. " triggered after " .. elapsed .. "s")
end

timer.delay(10, true, myCallback)

or simply provide an anonymous function:
timer.delay(10, true, function (obj, handle, elapsed)
    print("Timer with handle " .. handle .. " triggered after " .. elapsed .. "s")
  end)


text:
Q: Prove if we have a square unitary Matrix $Q$, then $\det(Q) = e^{i\theta}$ Prove if we have a square unitary Matrix $Q$, then $\det(Q) = e^{i\theta}$
Using $\det(Q)\det(\bar{Q}^T) = I$, I get to the stage $\det(\bar{Q})\det(Q)=1$, but can't do much else with it.
Thanks for the help.

A: It's easy to show that $\det(\bar{A})=\overline{\det(A)}$ for any square matrix. Thus you have
$$
\det(\bar{Q})\det(Q)=\overline{\det(Q)}\det(Q)=1
$$
which means that $|\det(Q)|=1$. Any complex number $z$ with $|z|=1$ can be represented as $z=e^{i\theta}$ for some $\theta\in[0,2\pi)$.


text:
Q: Python filter to remove outliers in image Writing CNN to classify pictures. I encountered a problem with garbage pixels. image The resulting network gives ~90% quality, it seems that it can be improved by averaging these pixels.
Is there a ready algorithm in numpy, opencv, etc. that allows to do this? Not normally smoothing, but specifically for these pixels. Or do I have to do it manually?

A: I agree that if you are using a CNN for some kind of classification you should train the network to handle this kind of noisy images. Maybe augment your dataset with some salt and pepper noise. Anyway, here's a possible solution for filtering out the outliers. It builds on the idea proposed by fmw42. These are the steps:

*

*Apply a median blur with a large kernel

*Convert the original (unprocessed) image to grayscale

*(Invert) Threshold the grayscale image with a low threshold value (e.g, 5) to create a mask for the outliers close to 0.

*Threshold the grayscale image with a high low threshold value (e.g., 250) to create a mask for the outliers close to 255.

*Combine both mask to create the outlier mask

*Use the outlier mask to adaptive-filter the original input image substituting the median values where necessary.

Let's see the code:
# Imports:
import cv2
import numpy as np

# image path
path = "D://opencvImages//noisyNumbers//"
fileName = "noisy01.png"

# Reading an image in default mode:
inputImage = cv2.imread(path + fileName)

# Apply median filter:
filteredImage = cv2.medianBlur(inputImage, ksize=11)

# Convert input image to grayscale:
grayscaleImage = cv2.cvtColor(inputImage, cv2.COLOR_BGR2GRAY)

The median filtering with a kernel size of 11 looks like this:

The outliers are practically gone. Now, let's put this aside for the moment and compute a pair of binary masks for both outliers:
# Get low mask:
_, lowMask = cv2.threshold(grayscaleImage, 5, 255, cv2.THRESH_BINARY_INV)

# Get high mask:
_, highMask = cv2.threshold(grayscaleImage, 250, 255, cv2.THRESH_BINARY)

# Create outliers mask:
outliersMask = cv2.add(lowMask, highMask)

The outliers mask is this:

Now, you really don't provide your original data. You provide an image most likely plotted using matplotlib. That's a problem, because the image you posted is processed and compressed. This results in some sharp edges around the outliers on the original image. One straightforward solution is to dilate the outliers mask a little bit to cover this compression artifacts:
# Set kernel (structuring element) size:
kernelSize = 3
# Set operation iterations:
opIterations = 1
# Get the structuring element:
maxKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (kernelSize, kernelSize))

# Apply dilation:
outliersMask = cv2.dilate(outliersMask, maxKernel)

The outliers mask now looks like this:

Ok, let's adaptive-filter the original input using the median blurred image and the outliers mask. Just make sure to reshape all the numpy arrays to their proper size for broadcasting:
# Re-shape the binary mask to a 3-channeled image:
augmentedBinary = cv2.merge([outliersMask, outliersMask, outliersMask])
# Apply the adaptive filter:
cleanedImage = np.where(augmentedBinary == (255, 255, 255), filteredImage, inputImage)

# Show the result
cv2.imshow("Adaptive Filtering", cleanedImage)
cv2.waitKey(0)

For the first image, this is the result:

More results:


text:
Q: Move files under GCS with renaming I want to write the following bash script which copies files from one GCS bucket to another with renaming options.
My input folder is gs://test-rtt-integration/result/frd/*.orc
and my destination folder is gs://test-rtt-integration/recent_files/frd
The  renaming of the copied file should be done based on the name provided from  gs://test-rtt-integration/complex-files/TAN/recent_files/today/frd
once the copy with renaming is done I need to clean gs://test-rtt-integration/result/frd
I tested the following commands, but they are not working properly
NAME = "$(gsutil ls gs://test-rtt-integration/complex-files/TAN/recent_files/today/frd)"
gsutil mv gs://test-rtt-integration/result/frd/*.orc   gs://test-rtt-integration/recent_files/frd/$NAME
gsutil rm -rf gs://test-rtt-integration/result/frd

( all .orc files and other files should be deleted)
But this is not working properly as I have to split the NAME based on / and get the last split , so if the result of split is called SPLIT , I  have to do gsutil mv gs://test-rtt-integration/result/frd/*.orc   gs://test-rtt-integration/recent_files/frd/$SPLIT
Any idea on how to do this?

A: The question is a little bit confusing. You say that you want to move files from one Google Cloud Storage bucket to another, but all the operations are made in one single bucket called test-rtt-integration.
However, as soon as you get the file location with the command gsutil ls gs://[BUCKET_NAME]/folder e.g. gs://[BUCKET_NAME]/folder/[FILENAME].orc, since the gs://[BUCKET_NAME]/folder/ part is always the same for all the objects in the folder, just replace it with null and you will get only the object name at the end as [FILENAME].orc etc.
I am not sure if this is exactly what you are looking for, but I did a little bit of coding myself and I have created a bash script that:

*

*Gets the name of each object from gs://[BUCKET_NAME]/from bucket folder

*Copy all objects from gs://[BUCKET_NAME]/from bucket folder to the gs://[BUCKET_NAME]/to/ bucket folder

*Delete all objects from gs://[BUCKET_NAME]/from bucket folder

Inside there are comments that explain how every operation works in details. If that is not exactly what you are looking for, you can get the basic idea of how that works and implement it in different way that will suit you better. I have tested the scrip myself in Google Cloud Shell and it is working. The example code can be found in GitHub.


text:
Q: Whats the Shortcut Key for inserting a Horitonzal Line  in Mozilla Thunderbird? Whats the Shortcut Key for inserting a Horitonzal Line<hr> in a message in Mozilla Thunderbird?
Without touching the mouse or going through the tideous menu every single time.
If NO keyboard shortcuts exist [as of yet], then:
1. How to programm/hack this in the configuration?
2. Are there addons that can bind menu items to a shortcut keystroke?

A: Unfortunately, there is not a direct shortcut, but it can be accomplished by sending two separate keystrokes.
First, use Alt + i to access the Insert Menu followed by o to insert a Horizontal line.


text:
Q: What is the difference between a group and match in .NET's RegEx? What is the difference between a Group and a Match in .NET's RegEx?

A: A Match is an object that indicates a particular regular expression matched (a portion of) the target text. A Group indicates a portion of a match, if the original regular expression contained group markers (basically a pattern in parentheses). For example, with the following code:
string text = "One car red car blue car";
string pat = @"(\w+)\s+(car)";
Match m = r.Match(text);

m would be match object that contains two groups - group 1, from (\w+), and that captured "One", and group 2 (from (car)) that matched, well, "car".

A: A Match is a part of a string that matches the regular expression, and there could therefore be multiple matches within a string.
Inside a Match you can define groups, either anonymous or named, to make it easier to split up a match. A simple example is to create a regex to search for URLs, and then use groups inside to find the protocol (http), domain (www.web.com), path (/lol/cats.html) and arguments and what not.
// Example I made up on the spot, probably doesn't work very well
"(?<protocol>\w+)://(?<domain>[^/]+)(?<path>/[^?])"

A single pattern can be found multiple times inside a string, as I said, so if you use Regex.Matches(string text) you will get back multiple matches, each consisting of zero, one or more groups.
Those named groups can be found by either indexing by number, or with a string. The example above can be used like this:
Match match = pattern.Match(urls);
if (!match.Success)
    continue;
string protocol = match.Groups["protocol"].Value;
string domain = match.Groups[1].Value;

To make things even more interesting, one group could be matched multiple times, but then I recommend start reading the documentation.
You can also use groups to generate back references, and to do partial search and replace, but read more of that on MSDN.


text:
Q: Построение графиков в Andriod Делаю мобильный клиент для биржы. Нужно строить графики котировок в реальном времени, а так же рисовать на них фигуры и линии технического анализа.
Хочется услышать свежее мнение  - какая библиотека для этого наиболее подходит.
В обсуждениях 2 годичной давности все хвалят эту MPAndroidChart. Актуально?

A: Возможно Android Arsenal вам поможет у них там есть рейтинг:
https://android-arsenal.com/tag/40?sort=rating


text:
Q: Javascript - Why does measuring time becomes inaccurate in a iterating function? Consider this piece of code
// Initialise the variables to check when the code started
let total_time = performance.now();
let recursions = 0;
function test() {
    recursions++;
    if (recursions === 60) {
        // Check how long it took to do 60 recursions
        console.log(`${performance.now() - total_time}ms`);
    }
// Timeout to call it 17ms later
setTimeout(() => test(), 17);
}
test();

This is meant to show when 60 recursions have happened to ensure that certain parts of my code are fired off correctly (without needing setTimeout as it's blocking) and I get between 1200 - 1600ms for no reason. I used a modified version that measured how long it took and it gave 0ms (for no reason). Anyone know why? And will the same happen in node.js?
Code used to measure how long it took to do one recursion
let start_time = performance.now();
let total_time = performance.now();
let measure = 0;
function test() {
    start_time = performance.now();
    measure++;
    if (measure === 60) {
        console.log(`${performance.now() - total_time}ms`);
    }
    console.log(`Taken ${performance.now() - start_time}`);
}
test();

A: It's not supposed to be very accurate as you might expect since the timeout can fire an event later when the page is busy with other tasks.
setTimeout is implemented in a way it's meant to execute after a minimum given delay, and once the browser's thread is free to execute it. so, for an example, if you specify a value of 0 for the delay parameter and you think it will execute "immediately", it won't. it will, more accurately, run in the next event cycle (which is part of the event loop - concurrency model which is responsible for executing the code).
So for conclusion, you can't use setTimeout if you expect a consistent, reliable
and accurate timing in scale of millisecond.
Please read reason for delays longer then specified - https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#reasons_for_delays_longer_than_specified
More about the JS event loop - https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop


text:
Q: Auto changing the gaps,font size based on application DPI in Flexmobile I am working on a mobile app for multi resolutions,for which the components in the screen should adjust itself based on the application DPI. How can i do this?

A: I would suggest you'd define multiple stylesheets that assign skins to your components. Each stylesheet assigns skins that render the components accordingly to the resolution/dpi used on the device.
The specific stylesheet need to be loaded and applied at runtime after determining the resolution/dpi.

A: Use the applicationDPI property on your main Application.  The views will automatically adjust based on whether the device is closest to 160, 240, or 320 DPI.
See also http://help.adobe.com/en_US/flex/mobileapps/WS19f279b149e7481c682e5a9412cf5976c17-8000.html


text:
Q: dotnetnuke localresourcefile does not return resource file name for dynamically loaded control I am using DNN 7.04.
I am trying to get a string from a resource file and have tried these:
var path1 = Localization.GetString("MyAdsPath.Text", LocalResourceFile);
var path2 = Localization.GetString("MyAdsPath.Text", LocalResourceFile + "/AdditionalInfo.ascx.resx");

path1 returns null and path2 returns the correct string from the resource file.
In both cases LocalResourcfile returns:
/desktopmodules/qEmployerCreateAd/App_LocalResources/
The problem is I don't want to hard code the resource file name as it will change when the language changes.
I think the issue is to do with the control being dynamically loaded.
Do I have to check the culture and then hard code the resource file name? Or is there a better solution?
thanks
Norb

A: My solution to this can be found in DNNSimpleArticle
But basically when loading the dynamic control, you just need to pass along the module configuration from the parent to it.
try
{
    var controlToLoad = "Controls/ArticleList.ascx";
    if (ArticleId > 0)
        controlToLoad = "Controls/ArticleView.ascx";

    var mbl = (dnnsimplearticleModuleBase)LoadControl(controlToLoad);
    mbl.ModuleConfiguration = ModuleConfiguration;
    mbl.ID = System.IO.Path.GetFileNameWithoutExtension(controlToLoad);
    phViewControl.Controls.Add(mbl);
}
catch (Exception exc) //Module failed to load
{
    Exceptions.ProcessModuleLoadException(this, exc);
}

A: I found a solution that works:
http://weblogs.asp.net/anasghanem/fixing-dotnetnuke-localization-for-child-and-dynamically-loaded-usercontrols
In case that link dies here is the solution:
Create a base UserCotrol class that inherits from PortalModuleBase and fix the LocalResourceFile like below :
public partial class BaseUserControl :  DotNetNuke.Entities.Modules.PortalModuleBase
{
// basicly this will fix the localization issue
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    string FileName =  System.IO.Path.GetFileNameWithoutExtension(this.AppRelativeVirtualPath);
    if (this.ID != null)
        //this will fix it when its placed as a ChildUserControl
        this.LocalResourceFile = this.LocalResourceFile.Replace(this.ID, FileName);
    else
        // this will fix it when its dynamically loaded using LoadControl method
        this.LocalResourceFile = this.LocalResourceFile + FileName + ".ascx.resx";
}
}


text:
Q: Some (but not all) static content proxied by nginx loads successfully I have nginx setup on my windows machine as a reverse proxy, listening on 443 over ssl. When I hit a particular url, it is supposed to serve a node js web application that I have running locally. It hits the application successfully - however, it loads some but not all of the web application's static content. Which files aren't loaded varies each time.
There are several css and JavaScript files that are supposed to be loaded. When I check the network tab of the Developer Tools in Chrome, it shows two of the files pending indefinitely, while the others have been loaded fine. Which two files varies each time.

This is my nginx.conf (I have substituted the actual urls for privacy's sake.):
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  0;
    client_max_body_size 1024M;

    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

    # time is in seconds
    proxy_connect_timeout       1000;
    proxy_send_timeout          1000;
    proxy_read_timeout          1000;
    send_timeout                1000;

    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    Host $host;

    server {
        listen 443;
        ssl on;
        ssl_certificate cert.pem;
        ssl_certificate_key cert.key;
        ssl_verify_client optional_no_ca;
        server_name  v-mysite.com;

        error_log logs/error.log debug;

        location / {
            proxy_pass https://pm-mysite.com:4434;
        }

        location /mja/ {
            proxy_pass https://pm-mysite.com:4433;
        }

        location /mja/cassette.axd/ {
            proxy_pass https://pm-mysite.com:4433/cassette.axd/;
        }

        location /mja/content/ {
            proxy_pass https://pm-mysite.com:4433/Content/;
        }

        location /api/myappcenter/ {
            proxy_pass https://pm-mysite.com:4333/;
       }

        location /api/documentation/myappcenter {
            proxy_pass https://qa-mysite.com:4433/documentation;
        }

        location /api/person/match {
            proxy_pass https://anothersite.com:43443/match;
        }

        location /api/sms/ {
            proxy_pass https://anothersite.com:44443/;
        }

        location /myapp/content/ {
            proxy_pass http://pm-mysite.com:5000/;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
        }

        location /api/myapp/ {
            proxy_pass http://pm-mysite.com:5000/api/;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
        }

        location ~* ^/(?!api)(?<alias>\w+)/myapp/index/(?<path>.*)$ {
            proxy_pass http://pm-mysite.com:5000/$path;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
            proxy_set_header Alias $alias;
        }
    }
}

I have set the nginx error log to debug, and included a (hopefully) relevant piece of it here. There might be an ssl read error of some sort occurring.
[debug] 9684#11312: *278 http process request line
[debug] 9684#11312: *278 http request line: "GET /myapp/content/js/resources.en.js HTTP/1.1"
[debug] 9684#11312: *278 http uri: "/myapp/content/js/resources.en.js"
[debug] 9684#11312: *278 http args: ""
[debug] 9684#11312: *278 http exten: "js"
[debug] 9684#11312: *278 http process request header line
[debug] 9684#11312: *278 http header: "Host: v-mysite.com"
[debug] 9684#11312: *278 http header: "Connection: keep-alive"
[debug] 9684#11312: *278 http header: "Cache-Control: max-age=0"
[debug] 9684#11312: *278 http header: "Accept: */*"
[debug] 9684#11312: *278 http header: "If-None-Match: "1d18a93e19632ee""
[debug] 9684#11312: *278 http header: "If-Modified-Since: Wed, 30 Mar 2016 14:53:12 GMT"
[debug] 9684#11312: *278 http header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36"
[debug] 9684#11312: *278 http header: "Referer: https://v-mysite.com/myapp/Index/AuLKHOtasdfasdfzGkmXOaUkAasdfL2uWQ"
[debug] 9684#11312: *278 http header: "Accept-Encoding: gzip, deflate, sdch"
[debug] 9684#11312: *278 http header: "Accept-Language: en-US,en;q=0.8,de;q=0.6"
[debug] 9684#11312: *278 http alloc large header buffer
[debug] 9684#11312: *278 malloc: 0237BEE0:8192
[debug] 9684#11312: *278 http large header alloc: 0237BEE0 8192
[debug] 9684#11312: *278 http large header copy: 493
[debug] 9684#11312: *278 SSL_read: 3577
[debug] 9684#11312: *278 SSL_read: -1
[debug] 9684#11312: *278 SSL_get_error: 2

I'm pretty new to nginx, to please go easy on me. :)


text:
Q: Como criar um JSON usando o jquery? Como eu faço para criar um JSON com vários nomes diferentes?
Igual:
[{nome: "joão"}, {nome: "pedro"}]
Alguém poderia me dar um exemplo?

Eu tentei fazer assim, mas porque ele retorna sempre o último item duas vezes? Tipo João na primeira e logo, Pedro duas vezes?
  $(".item-tbody .nome").each(function ()
   {
       obj.nome = $(this).parent().find('.nome').text();

        arrayObj.push(obj);

         nomeArray = JSON.stringify(arrayObj);
          alert(nomeArray);

   });

A: O seu JSON não é válido ! Cole ele nesse site e valide-o, o seu JSON retorna:

Expecting string or }, not [.

Eu criei um JSON válido de nomes para você. Lembrando que { } = objeto e [  ] = Array.  Leia mais sobre JSON aqui.
[{ "nome":"João"},{"nome":"Pedro"}]

obj =
[
   {
      "nome":"João"
   },
   {
      "nome":"Pedro"
   }
]

console.log(obj[0].nome)
console.log(obj[1].nome)


text:
Q: Can you zip or use a custom join operator in non-expression linq? I have multiple sequences I want to zip in a more readable way such that I could write
a.Zip(b)

in query syntax as
From a in Foo1
Join b in Foo2

without the result being a cross join
or
From a in Foo1
Zip b in Foo2

A: The standard Zip method allows you to write something like (using C#):
from t in first.Zip(second, (f, s) => new { First = f, Second = s }
select ... t.First ... t.Second;

I think this should be readable enough. Your question seems to suggest that you'd like to be able to create your own keyword e.g. zip and extend the C# query expressions using it. This is not possible in C# or Visual Basic (but I agree it would be nice in a way).
With some effort, you can redefine what standard C# query construct does, so that join would behave like zip (In that case, the equals part of the query would not be needed, so you'd have a lot of syntactic noise). Possibly, you could also redefine what from clause. I didn't try it, but I believe you could get something like:
from f in first.Zip()
from s in second.AddToZip()
from t in second.AddToZip()
select ... f ... s ... t ...;

I wrote an article that describes how to do this redefining for the group by clause (Using custom grouping operator in LINQ), so this can give you an idea how this can be done.
(But honestly, I think that the standard Zip method should be fine. The redefinition of operators is quite subtle. The group by example may be more appealing because grouping using method is uglier, but even that is on the edge...)


text:
Q: Help with GROUP BY clause need your help with GROUP BY clause.
I have two tables: Managers and Clients (I simplified it for a question).
Managers:
managerId int PK,
ManagerName nvarchar(50)

and
Clients:
ClientId int,
ClientName nvarchar(50),
ManagerId int, WhenAdded datetime

I store managers list in Managers table. Each client from Clients table has a corresponding manager.
I want a sql query which returns following table:
ManagerName nvarchar(50),
NumberOfClients int

My problem is:
if manager doesn't have a client(s). Sql query doesn't include ManagerName in resulting table.
I tried this query:
SELECT M.ManagerName, COUNT(*)
FROM
Clients AS C left join Managers AS M
ON
C.ManagerId = M.ManagerId
GROUP BY
M.ManagerName

Second question
Same as a first question, but if I want to add a where clause to the WhenAdded field in Clients). Query must return ManagerName and NumberOfClients even if NumberOfClients=0.

A: You can use this:
SELECT ManagerName, (SELECT Count(ClientID) FROM Clients C WHERE
    C.ManagerID=M.ManagerID) As NumberOfClients FROM Managers M;

or this:
SELECT ManagerName, Count(C.ClientID) As NumberOfClients FROM Managers M
    LEFT JOIN Clients C ON M.ManagerID=C.ManagerID GROUP BY M.ManagerID,
    M.ManagerName;

The problem with your query is that you're using Clients table as basic table.
For the second question you can use this:
SELECT ManagerName, (SELECT Count(ClientID) FROM Clients C WHERE
    WhenAdded<DATEADD(day, 1, GETDATE()) AND M.ManagerID=C.ManagerID) As
    NumberOfClients FROM Managers M;

A: This should work. Not very optimized though!
select m.ManagerName , count(c.ManagerId) from Managers m, Clients c where
m.ManagerId = c.ManagerId group by c.ManagerId


text:
Q: Getting error while Get parameters from restapi and use that parameter in python AWS API

https://******.****.amazonaws.com/prod/api/users/{ID}

I want to pass ID in URL and get that id using AWS lambda function through Python.
I have to access that id through python.
Python Code is
import boto3
def lambda_handler(event, context):
   dynamodb = boto3.resource('dynamodb')
   table = dynamodb.Table('Users')
   response = table.get_Item(key={'ID':event['pathParameters']['ID']});
  return response


text:
Q: Using timer to refresh interface, keep getting "There is already an open DataReader associated with this Connection which must be closed first." I've been using a timer to refresh the listview on my application, but after half a second, I get the error message at first try/catch method in RefreshPlot() in PlotComponent.cs:

An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in Marketplace.exe but was not handled in user code
Additional information: There is already an open DataReader associated
  with this Connection which must be closed first.

What is this down to? I'm tried using using and try/catch, so I am not really clear on the mistake I could be making. When I disable the timer everything works well. But I need to access the database every 0.5 seconds in order to refresh the listview.
If I am not doing it the correct way is there anything else I can do?
Code is as follows:
MainWindow.cs
public MainWindow()
{
    InitializeComponent();

    // Reset lists
    SetPlotList(_filterPlotReference);

    // Refresh lists
    Refresh();
}

public void Refresh()
{
    var myTimer = new System.Timers.Timer();
    myTimer.Elapsed += RefreshPlotList;
    myTimer.Interval = 500;
    myTimer.Enabled = true;
}

public void RefreshPlotList(object source, ElapsedEventArgs e)
{
    PlotComponent.RefreshPlot();
    Dispatcher.Invoke(() =>
    {
        if (!string.IsNullOrWhiteSpace(FilterTextBox.Text) &&
            (!Regex.IsMatch(FilterTextBox.Text, "[^0-9]")))
        {
            _filterPlotReference = Convert.ToInt32(FilterTextBox.Text);
        }
    });
    SetPlotList(_filterPlotReference);
    FocusPlotItem(_focusPlotReference);
}

public void SetPlotList(int filterReference)
{
    // Fill plot list view
    List<PlotComponent.PlotList> plotList = PlotComponent.SelectPlotLists(filterReference);

    // Find the plot list item in the new list
    PlotComponent.PlotList selectPlotList =
        plotList.Find(x => Convert.ToInt32(x.PlotId) == _focusPlotReference);

    Dispatcher.Invoke(
        (() =>
        {
            PlotListView.ItemsSource = plotList;
            if (selectPlotList != null)
            {
                PlotListView.SelectedItem = selectPlotList;
            }
        }));

    int jobSum = 0;
    int bidSum = 0;
    foreach (PlotComponent.PlotList item in PlotListView.Items)
    {
        jobSum += Convert.ToInt32(item.Jobs);
        bidSum += Convert.ToInt32(item.Bids);
    }

    // Determine job/bid list ratio
    Dispatcher.BeginInvoke(
        new ThreadStart(() => JobBidRatioTextBlock.Text = jobSum + " jobs - " + bidSum + " bids"));
}

private void FocusPlotItem(int focusPlotReference)
{
    Dispatcher.Invoke(
        (() =>
        {
            PlotComponent.PlotList plotList =
                PlotListView.Items.OfType<PlotComponent.PlotList>()
                    .FirstOrDefault(p => Convert.ToInt32(p.PlotId) == focusPlotReference);
            if (plotList == null) return;
            //get visual container
            var container = PlotListView.ItemContainerGenerator.ContainerFromItem(plotList) as ListViewItem;
            if (container == null) return;
            container.IsSelected = true;
            container.Focus();
        }));
}

DbConnect.cs
http://pastebin.com/pZ0PGrg1
PlotComponent.cs
http://pastebin.com/xiRhKyMM
Thanks so much for your help in advance.

A: Here is an example to lock timer till it finishes its work:
bool timerRunning = false; // define it as a global variable

// then in your timer process add this easy check
public void RefreshPlotList(object source, ElapsedEventArgs e)
{
    if(timerRunning) return; // return if it is busy
    timerRunning = true;  // set it to busy

    PlotComponent.RefreshPlot();
    Dispatcher.Invoke(() =>
    {
        if (!string.IsNullOrWhiteSpace(FilterTextBox.Text) &&
            (!Regex.IsMatch(FilterTextBox.Text, "[^0-9]")))
        {
            _filterPlotReference = Convert.ToInt32(FilterTextBox.Text);
        }
    });
    SetPlotList(_filterPlotReference);
    FocusPlotItem(_focusPlotReference);

    timerRunning = false;  // reset it for next time use
}

P.S: I edited the other answer by adding (exactly) this answer, then I got rejected, the peer review says

This edit was intended to address the author of the post and makes no
  sense as an edit. It should have been written as a comment or an
  answer

I have no doubt that they did read the edit and evaluate it, not to mention the fact that it doesn't fit in a comment, so here I post it as an answer

A: Can you disable the timer until the RefreshPlotList function finishes?
May be at the start of the function disable the timer and at the end of RefreshPlotList function Enable the timer. I guess RefreshPlotList function is taking more than .5 seconds and another call is made before the current one is finished.


text:
Q: display contents of txt file uploaded with ajax I've been able to get upload a .txt file to my site using ajax, but I also want to display the contents of the .txt file on my site. I'm not sure how to go about doing this. Thanks!
here is my html
<!DOCTYPE html>

            <form action="http://malsup.com/jquery/form/file-echo2.php" method="post" enctype="multipart/form-data">
                <input type="file" name="myfile"/>
                <input type="submit" value="Submit File"/>
            </form>

0%

here is my jquery
$(document).ready(function() {

(function() {

var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');

$('form').ajaxForm({
    beforeSend: function() {
        status.empty();
        var percentVal = '0%';
        bar.width(percentVal)
        percent.html(percentVal);
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        bar.width(percentVal)
        percent.html(percentVal);
    },
    success: function() {
        var percentVal = '100%';
        bar.width(percentVal)
        percent.html(percentVal);
    },
complete: function(xhr) {
    status.html(xhr.responseText);
}
});

})();

});

here is my php
<?php
foreach($_FILES as $file) {
   $n = $file['name'];
    $s = $file['size'];
   if (is_array($n)) {
      $c = count($n);
      for ($i=0; $i < $c; $i++) {
         echo "
uploaded: " . $n[$i] . " (" . $s[$i] . " bytes)";
      }
   }
   else
      echo "
uploaded: $n ($s bytes)";
}
?>

A: You can just send it back within the ajax request:
in file-echo2.php:
<?php

foreach($_FILES as $file) {
   $n = $file['name'];
   $s = $file['size'];

   if (is_array($n)) {
      $c = count($n);
      for ($i=0; $i < $c; $i++) {
         if (move_uploaded_file($n[$i], '/path/where/you/put/that/file.txt')) {
            echo "uploaded " . $n[$i] . " (" . $s[$i] . " bytes):\n";
            echo file_get_contents('/path/where/you/put/that/file.txt');
         }
      }
   }
   else {
      if (move_uploaded_file($n, '/path/where/you/put/that/file.txt')) {
            echo "uploaded " . $n . " (" . $s . " bytes):\n";
            echo file_get_contents('/path/where/you/put/that/file.txt');
      }
   }
}

A: var fileText = load('file_name.txt');

you can find more solution by going here:
http://forum.jquery.com/topic/reading-values-from-text-file


text:
Q: How do I discourage bad programming practice in SO questions? This question can apply to any computer language, but my example is C++.
Many questions (quite helpfully) supply sample code (which I can paste into an IDE and try), but use using namespace std; which is a very bad practice in many cases.
I am concerned that with so many questions including this bad practice, this will be seen as normal and just end up promoting bad practice all over SO and Google.
I think that there are a number of students coming to SO with real questions, but somehow having picked up a bad habit.  We need to answer the valid questions, but promote good habits as well.
Do I need more rep on SO to be able to edit the questions?
Can questions with some tags be flagged with some warnings to the writer?

A: When this happens and I think it's worthy of it, I just comment on the code.
For the specific issue of using namespace std;, many tutorial sites and even books, use it in their examples. It's simply a way to save time and space for examples. It's generally well understood that libraries and production code should avoid doing so.

A: this is what voting and commenting are for -- When you see a bad answer, whether it's unclear, doesn't solve the problem, or promotes bad practice, then you have the option to downvote -- you should also leave a comment to explain why you believe it to be bade practice too.
Of course, you could always leave an answer of your own that doesn't exhibit the same problems, and explain why you think it's a better answer

A: Just edit the question.


text:
Q: Flatten deeply nested list of dataframes Consider this nested list of dataframes:
df <- data.frame(x = 1:5, y = letters[1:5])
l <- list(df, list(df, df), list(df, list(df, df, list(df))), list(df), df)

How can one get from this deeply nested list to a simple list of dataframes:
list(df, df, df, df, df, df, df, df, df)

Usual solutions (like here) fails to keep dataframes' structure.

A: A convenient option is to use rrapply:
rrapply::rrapply(l, classes = "data.frame", how = "flatten")

Check whether it's the same as the desired output:
identical(list(df, df, df, df, df, df, df, df, df),
          rrapply(l, classes = "data.frame", how = "flatten"))

[1] TRUE

A: Or using a base R recursive function:
unnestdf <- function(x)
{
  if (is.data.frame(x))
    return(list(x))
  if (!is.list(x))
    return(NULL)
  unlist(lapply(x, unnestdf), F)
}

unnestdf(l)

#> [[1]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[2]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[3]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[4]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[5]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[6]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[7]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[8]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e
#>
#> [[9]]
#>   x y
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
#> 5 5 e


text:
Q: Скругление углов у ImageButton Помогите закруглить углы у Image Button
<ImageButton
        android:id="@+id/bottle"
        android:src="@drawable/bottle"
        android:background="@drawable/rouncorners"
        android:layout_width="100dp"
        android:layout_height="100dp"/>

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners android:radius="10dp"/>

</shape>

A: Надо еще в коде вызвать:
ImageView.setClipToOutline(true);

иначе ImageView не будет обрезаться по границам фона (то есть будет с острыми углами)
Как альтернативу можно использовать RoundedImageView:
<com.makeramen.roundedimageview.RoundedImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:src="@drawable/photo1"
    android:scaleType="fitCenter"
    app:riv_corner_radius="30dip"
/>


text:
Q: How to filter on managed metadata column using REST API in sharepoint 2010? I am accessing couple of forms libraries and lists from SharePoint sites using the ReST API at _vti_bin/listdata.svc. I can use filters like $Select, $Expand etc and it works fine.
However few of these lists do contain columns from managed metadata term store. I can see the values in the view when I login to the site. But I do not get those columns in the data retrieved using the API.
Can someone help me to understand how I may get the data?

A: According to a few articles, not all types of columns are available/supported via REST in SharePoint 2010, including managed metadata columns.
Not Supported

*

*Managed Metadata

*Managed Metadata (Multi)

*Publishing HTML

*Publishing Hyperlink

*Publishing Image

*Media Field

*Summary Links

*Publishing Image

Source: http://platinumdogs.me/2013/03/14/sharepoint-adventures-with-the-rest-api-part-1/


text:
Q: best way to get a callback when a radiobutton is clicked in javascript I have HTML like this:
<input type="radio" name="v" value="1"> 1

<input type="radio" name="v" value="2"> 2

<input type="radio" name="v" value="3" checked> 3

I want to know how to monitor all of those radio buttons. I could have many more than 3.
One thing I considered is to have an onclick function for all of them. Is that the right way, or is there a neater way to register a common javascript function when the radio button set has changed?

A: In addition to Markandey's comment: if you are using jquery, you can use attribute selectors instead of classnames without too much hassle so that you have minimal code.

$("input[name=v]").click(mycallback);

In the mycallback function, 'this' will refer to the element that was clicked.
e.g.
mycallback = function(){
  alert($(this).val());
};

Putting an onclick attribute on each element creates a maintenance headache.  It also prevents you from treating HTML and JavaScript as separate layers - a data layer and a behaviour layer - in the same way that CSS is your presentation layer.
Listening for events is a more mature way of developing JavaScript.  Initially it takes a bit of getting used to (as it is no longer obvious from the element alone that some functionality will get triggered when you click on it) but you soon find your way around that by organising and commenting your code better.
Edited because I saw I hadn't turned the 'this' into a jquery object, and when you are in the callback 'this' is the native DOM object so .val() wouldn't work.

A: You can add an event listener to the parent of these elements. Events bubble up the DOM tree so you only need to attach one handler.
See an example here: http://jsfiddle.net/cLzBV/3/

A: <input class="someclass" type="radio" name="v" value="1"> 1

<input class="someclass" type="radio" name="v" value="2"> 2

<input class="someclass" type="radio" name="v" value="3" checked> 3

function yourcallback()
{

}
$('.someclass").click(yourcallabck);

This the way you can do using jquery

A: How do I register a javascript event handler to an element that hasn't been added to the page yet...
This is a similar post with good solution how to have an 'onclick' function for all of them.
And next code I see useful for you:
document.onclick = myRadioButtonOnClickHandler;

function myRadioButtonOnClickHandler(e) {
    var realTarget = e ? e.target : window.event.srcElement;
    if (realTarget.nodeName.toLowerCase() === 'input' && realTarget.type === 'radio' ) {
        doSomething();
    }
}

Hope it helpful.

A: You can use Jquery add class to every radio such as "RadioClass" add jquery file to your page and use the code below...
$(document).ready(function() {
    $('.RadioClass').click(function () {
        alert($(this).val());
    });
});


text:
Q: Double quotes on AngularJS Highcharts data I am using AngularJS Highcharts with data from a web service call, and DataStore variable holds my original data while the one quoted is after JSON conversion, though I don't know how Highcharts get this data from the controller.
DataStore =  [[04/10/2015,534.827468425035],[04/10/2015,213.072995232185]];
DataStore_After_JSON_Conversion = "[[04/10/2015,534.827468425035],[04/10/2015,213.072995232185]]"

Consider the following fiddle, where I added double quotes on the data and it doesn't work, in the chart config section.
http://jsfiddle.net/yishagerew/4s1u219r/
and here is the working version with no double quotes. http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/
I used String.replace like dataStore.replace(expr) and everything so to remove the quotes but it will add anyway when it generates the JSON format.
Would you please help me on how to remove this quotes during which it generates JSON file from angular scope variable?
Thanks,


text:
Q: Best way to find data in json by jquery i tried this but did not work and getting error SyntaxError: invalid property id
js fiddle link http://jsfiddle.net/mm49u6wv/
var data={
 { "Id": "12345", "Name": "Acme Widget 1", "Price": "£25.99", "Status": "In Stock"  },
 { "Id": "67890", "Name": "Acme Widget 2", "Price": "£28.99", "Status": "In Stock"  },
 { "Id": "11123", "Name": "Acme Widget 3", "Price": "£15.99", "Status": "In Stock"  },
 { "Id": "14156", "Name": "Acme Widget 4", "Price": "£33.99", "Status": "In Stock"  }
}

$.each(data, function(i, v) {
    alert(v.id);
});

A: Keys are case sensitive so id and Id are different. Also correct your JSON array. Try this:
var data= [
 { "Id": "12345", "Name": "Acme Widget 1", "Price": "£25.99", "Status": "In Stock"  },
 { "Id": "67890", "Name": "Acme Widget 2", "Price": "£28.99", "Status": "In Stock"  },
 { "Id": "11123", "Name": "Acme Widget 3", "Price": "£15.99", "Status": "In Stock"  },
 { "Id": "14156", "Name": "Acme Widget 4", "Price": "£33.99", "Status": "In Stock"  }
];

$.each(data, function(i, v) {
    alert(v.Id);
});

Here is the jsfiddle.

A: Your json array is invalid it should be :
var data=[
 { "Id": "12345", "Name": "Acme Widget 1", "Price": "£25.99", "Status": "In Stock"  },
 { "Id": "67890", "Name": "Acme Widget 2", "Price": "£28.99", "Status": "In Stock"  },
 { "Id": "11123", "Name": "Acme Widget 3", "Price": "£15.99", "Status": "In   Stock"  },
 { "Id": "14156", "Name": "Acme Widget 4", "Price": "£33.99", "Status": "In Stock"  }
];

and inside $.each id should be Id :
$.each(data, function(i, v) {
alert(v.Id);
});

A: you created invalid JSON array. DEMO
  var data=[
    { "Id": "12345", "Name": "Acme Widget 1", "Price": "£25.99", "Status": "In Stock"  },
    { "Id": "67890", "Name": "Acme Widget 2", "Price": "£28.99", "Status": "In Stock"  },
    { "Id": "11123", "Name": "Acme Widget 3", "Price": "£15.99", "Status": "In Stock"  },
    { "Id": "14156", "Name": "Acme Widget 4", "Price": "£33.99", "Status": "In Stock"  }
];

 $.each(data, function(i, v) {
   alert(v.Id);
 });

As mentioned in @Beginner answer you need to take care of key case. Keys are case sensitive