text:
Q: foreach warning coming up My following code works (it returns the value of text in 2d array).  Now, this is just a proof of concept for something more I want to do (so that's why the logic is stupid)
function searchArrayFor($array, $id, $searchFor) {
    $index = 0;
    foreach ($array as $key => $value)
    {
        return $value[1];
    }
}

So I noticed in my log file, that I am constantly getting "PHP Warning:  Invalid argument supplied for foreach()".  Everything looks right, and returns the value I want, any ideas on why I keep getting this error?  I really don't want to be spamming the log file with every page load.
using PHP version 5.3.28 (I know, really old version).
Thanks

A: Try this I think you might have variables that are not array
function searchArrayFor($array, $id, $searchFor) {
    $index = 0;
    if(is_array($array)) {
        foreach ($array as $key => $value)
        {
            return $value[1];
        }
    }
    // Maybe add ELSE here and do a die($array); to see which value is not array
}

I believe this will take care of your array warning, let me know if that works.
Cheers


text:
Q: Adjusting UIImageView size and location based on the size of image fetched from service In my iOS7 app I have view just like profile page in any social networking site. I have a profile image in top left corner. I am fetching the image from service url and loading it to a UIImageview.
My problem is, I have to increase the size of this image view when the size of the image from service is big. And also i have to adjust other UILabels beside this image view. I am using this code to get the size of image from url:
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
CGSize size = img.size;

A: I don't know initWithData:cache: method on UIImage class, is this category thing?
Anyway you can make UIImageView dimension to fit content UIImage by [imageView sizeToFit].
If you want to adjust scale, use [UIImage imageWithData:data scale:scale].
NSString *path = @"http://www.example.com/example@x2.png"
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data scale:2.0];
_imageView.image = img;
[_imageView sizeToFit];

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I understand this big difference in speed: A friend of mine found a huge difference in runtime speed between these two
n=10^7;
(*1*) Timing[x = Table[Sin[2.2];, {i, n}];]
(*2*) Timing[x = Table[Sin[2.2], {i, n}];]

On computer, I get

{5.682385, Null}{0.205839, Null}

Just by removing the semi-colon, it makes the code run 20 times faster.  How do I understand why that is?

A: I will guess that the time needed to create a stock a packed array is significantly faster than that for filling a regular expression, even if every element is Null. For one, it is possible that Table, being a function that holds it arguments, preprocesses to the point of knowing (well, suspecting) that everything is a machine double in the fast case, and mostly avoiding the main evaluator thereafter (in effect behaving as though one had used Compile, to the level of C code). Also there is the actual storing: once we are in the packed array world it is only a matter of indexing into an array of machine numbers, and this should only involve fast memory accesses. With an ordinary expression the accessing, and hence setting, will be less direct.
There may be other wrinkles associated with producing two values per iteration (the sine, and Null). If we create a table of exact values, like so, it is somewhere in between in speed: Timing[x3 = Table[Sin[2], {i, n}];]. Moreover the difference is not entirely about doing two evaluations, because this next variant is still faster than the one with the semicolon: Timing[x4 = Table[Sin[2]; Sin[3], {i, n}];]. So I guess there is something about handling the Null that adds a bit of complexity.


text:
Q: clicking on link through ref created with React.useRef issuing Illegal invocation error message I'm trying to fetch data, build a csv from the data, and then download it with one click, but unfortunately, I'm only able to get as far as storing the data in state.  The code is as follows with a mockAPI:
import React, {useState, useRef, useEffect} from "react";
import ReactDOM from "react-dom";
import {CSVLink} from 'react-csv'
import get from 'lodash.get';
import isEmpty from 'lodash.isempty'

function App() {
  const csvLink = useRef();
  const [state, setState] = useState({data:[], headers: []});
  useEffect(() => {
    const clicker = get(csvLink, 'current.link.click');
    !isEmpty(state.data) && clicker && clicker();
  }, [state])
  const mockFetch = () => {
    setTimeout(() => {
      const headers = ['name', 'age']
      const data = [{name:'foo', age: 30},{name: 'bar', age: 40}]
      setState({data, headers})
    },0)
  }
  return (

click me

      <CSVLink
          headers={state.headers}
          data={state.data}
          filename="data.csv"
          ref={csvLink}
       />

  );
}

I get this error:
Uncaught TypeError: Illegal invocation
    at get-csv.js
    at commitHookEffectList (react-dom.development.js:17283)
    at commitPassiveHookEffects (react-dom.development.js:17307)
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:199)
    at invokeGuardedCallback (react-dom.development.js:256)
    at commitPassiveEffects (react-dom.development.js:18774)
    at wrapped (scheduler-tracing.development.js:207)
    at flushPassiveEffects (react-dom.development.js:18822)
    at dispatchAction (react-dom.development.js:13530)


text:
Q: How to kill the Warden How do you defeat the Warden in Minecraft?

A: If you want to cheeze him, then get a bow or two and infinity/lots of arrows. Make a hole then get the Warden stuck in it, then go 19 blocks away from him. When you're there just shoot him with arrows untill he dies.


text:
Q: OpAmp circuit with diodes: conduction conditions Consider the circuit below, where \$\ v_2\$ is an arbitrary input voltage and not necessarily equal to 3V as in the image. Both diodes and the OpAmp are ideal.

If only diode 1 is conducting or if both are, the output voltage, \$\ v_0\$, would be given by $$ v_0=v_2 +2V$$ If only diode 2 is conducting the output would be $$ v_0=2v_2$$ those two results where obtained by application of the standard rules (negative feedback, infinite input impedance...).
What I can't figure out is for which values of \$\ v_2\$ each situation is verified. According to the solutions the first situation is verified for \$\ v_2\leq 2\$ and the second for \$\ v_2\geq 2 \$.

A: Lets analyse this circuit by Kirschoffs law:
as long as your (perfect) OPAMP is not saturated it tries to regulate the output like like that the diferential input is 0V.
M1: \$U_{R1} + u_{diff} - V_2 = 0 => U_{R1 }= V_2\$
M2: \$-U_{R1} + U_{D1} - V_1 + U1_{OUT} = 0 => U1_{OUT} = V_2 - U_{D1} + V_1\$
M3: \$-U_{R1} - U_{D2} - U_{R2} + U1_{OUT} = 0 => U1_{OUT} = V_2 + U_{D2} + U_{R2}\$
Lets say both diodes are ideal and conduct @0.5V
And lets also say the part D1 is not assembled then you get:
\$U1_{OUT} = 2*V_2+0.5V\$ (D2 is always conducting a \$U1_{OUT}\$ always bigger than \$V_2\$).
With this knowledge we add now D1 and get:
\$2*V_2+0.5V = V_2 - U_{D1} + V_1\$
\$V_2 + 0.5V = -U_{D1} + V_1\$
\$V_2 = -2*0.5V + V_1\$ => D1 is conduction between \$V_2=0\$ and \$V_2 = 1V\$
So between \$V_2 = -VDD..1V\$ voltage \$U1_{OUT}\$ is determined by:
\$U1_{OUT} = V_2 + V_1 - U_{D1} = V2 + 1.5V\$
Above \$V_2 = 1V..VSS\$ its determined by:
\$U1_{OUT}=2*V_2+V_{D2}\$


text:
Q: Absolutely positioned div containing a child div with overflow hidden which contains 2 divs, one fixed height and one scrolling A web app has the following structure but the scroll goes off the page. Any ideas what is going wrong?
http://jsfiddle.net/kYEES/
HTML

Fixed height div

Scrolling div

CSS
* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

.wrapper {
  position: absolute;
  height: 100%;
  width: 100%;
}

.container {
  background: lightgray;
  height: 100%;
  overflow: hidden;
  padding: 10px;
  position: relative;
}

.fixed-height {
  background-color: yellow;
  height: 40px;
  padding: 5px 10px;
}

.scrolling-height {
  background-color: green;
  bottom: 0;
  height: 100%;
  overflow-y: scroll;
  margin-bottom: 20px;
  padding: 5px 10px;
  position: absolute;
  top: 40px;
}

A: Something like this: http://jsfiddle.net/DhWm5/3/
I gave your container a position: relative and your scrollable div an absolute position:
.container {
    background: lightgray;
    height: 100%;
    padding: 10px;
    position:relative;
}
.scrolling-height {
    background-color: green;
    margin-bottom: 50px;
    overflow-y: scroll;
    padding: 5px 10px;
    position:absolute;
    top: 50px; bottom: 0;
}

The top: 50px is to allow for the fixed height div and its padding;


text:
Q: AHK if/else of output from Custom Message Box Function I've been trying to create a script that displays message boxes conditioned on  the output from another customized message box with more than 3 options.
The custom functions are taken form this thread http://www.autohotkey.com/board/topic/29570-function-custom-msgbox-custom-buttons/page-2
I've tried both the CMsgbox and the MsgBoxV2 functions, running into the same problem. The Message "IT WORKED!" testing with if(condition) will  always appear regardless of whether pressing any of the Sym|&Go|&C options, and the message "worked" will never appear regardless of actually pressing C, In other words no specificity or sensitivity regarding variable testing.
!o::
var := MsgBoxV2("Question11","Hi, what's up??","Sym|Go|C","24")
Msgbox 4,, You Pressed %var%

if (%var% = C)
{
    Msgbox 4,, IT WORKED!
}

IfEqual, %var%,C
{
  Msgbox 4,, worked
}
return

!e::
var := CMsgbox( "s", "d", "*&Sym|&Go|&C","",1 )
Msgbox 4,, You Pressed %var%
if (%var% = C)
{
    Msgbox 4,, IT WORKED!
}

IfEqual, %var%,C
{
  Msgbox 4,, worked
}
return

I don't know if this is because I've misunderstood the if/Else testing in ahk, or if the output from these custom functions cannot be tested, or both.
One solution would be to figure out what type of variable %var% is, but I've not been able to find a way to figure that out either.
Thanks for reading and hope you guys can help.
here are the custom message functions for testing.
MsgBoxV2(Title="",Text="",Buttons="",IconPath="",Timeout="",Font="",Schriftart="Arial",Colors="||",WindowStyles="",GuiNr = "")
{
Static Stat2,Stat1
Col1:="0xFFFFFF" ,Col2:="0x000000",Col3:="0x000000", Color1:="", Color2:="", Color3:=""
Loop, Parse, Colors,`|
Color%A_Index% := (A_Loopfield = "") ? Col%A_Index% : A_Loopfield
Loop 3
Color%A_Index% := (Color%A_Index% = "") ? Col%A_Index% : Color%A_Index%
if instr(WindowStyles,"+altsubmit")
{
AltSub := "1"
Stringreplace,WindowStyles,WindowStyles,`+altsubmit
}
Gui, Color, %Color1%,%Color1%
Gui, Font, s9
Gui, Font, %Font%, %Schriftart%
X := 20 ,Y := 20
ifexist, %IconPath%
{
Gui, Add, Picture, x20 y20 w32 h32, %IconPath%
X := 70 ,Y := 30
} else
if IconPath is integer
{
Gui, Add, Picture, x20 y20 icon%IconPath% w32 h32, %A_WinDir%\system32\shell32.dll
X := 70 ,Y := 30
}
Gui, Add, Text, x%X% y%Y% c%Color2% vStat2, %Text%
GuicontrolGet, Stat2, Pos
X2 = 10
Y2 := (Stat2Y + Stat2H < 52) ? 82 : Stat2Y + Stat2H + 30
HMax = 0
Gui, Add, Text, vStat1 +border -background
Loop, Parse, Buttons,|,`|
{
Gui, Add, Button, x%X2% w100 Y%Y2% gExButton , %A_Loopfield%
ButT%A_Index% := A_Loopfield
Guicontrolget, Button%A_Index%,Pos
if (HMax < Button%A_Index%H)
HMax := Button%A_Index%H
ABut := A_Index
X2 += 110
}
Loop %ABut%
Guicontrol, Move, Button%A_Index%,h%HMax%
Gui, %WindowStyles%
Gui, Show, Autosize Center,%Title%
Guicontrol, Move, Stat1, % "X-1 Y" Y2 - 10 " W" 1400 " h" 41 + HMax
Guicontrol, -Background +hidden, Stat1
Guicontrol, show, Stat1
Gui, +LastFound
WinGet, G_id
if Timeout !=
if Timeout is integer
settimer, Timeout, %Timeout%
Winwait, ahk_id %G_id%
retval = 0
while winexist("ahk_id " G_id)
sleep 100
if !AltSub
return ButT%retval%
else
return retval
Timeout:
if Timeout =
return
GuiClose:
Gui, destroy
return
ExButton:
MouseGetPos,,,, Control
Stringreplace,retval,Control,Button
Gui, destroy
return
}

;-------------------------------------------------------------------------------
; Custom Msgbox
; Filename: cmsgbox.ahk
; Author  : Danny Ben Shitrit (aka Icarus)
;-------------------------------------------------------------------------------
; Copy this script or include it in your script (without the tester on top).
;
; Usage:
;   Answer := CMsgBox( title, text, buttons, icon="", owner=0 )
;   Where:
;     title   = The title of the message box.
;     text    = The text to display.
;     buttons = Pipe-separated list of buttons. Putting an asterisk in front of
;               a button will make it the default.
;     icon    = If blank, we will use an info icon.
;               If a number, we will take this icon from Shell32.dll
;               If a letter ("I", "E" or "Q") we will use some predefined icons
;               from Shell32.dll (Info, Error or Question).
;     owner   = If 0, this will be a standalone dialog. If you want this dialog
;               to be owned by another GUI, place its number here.
;
;-------------------------------------------------------------------------------

CMsgBox( title, text, buttons, icon="", owner=0 ) {
  Global _CMsg_Result

  GuiID := 9      ; If you change, also change the subroutines below

  StringSplit Button, buttons, |

  If( owner <> 0 ) {
    Gui %owner%:+Disabled
    Gui %GuiID%:+Owner%owner%
  }

  Gui %GuiID%:+Toolwindow +AlwaysOnTop

  MyIcon := ( icon = "I" ) or ( icon = "" ) ? 222 : icon = "Q" ? 24 : icon = "E" ? 110 : icon

  Gui %GuiID%:Add, Picture, Icon%MyIcon% , Shell32.dll
  Gui %GuiID%:Add, Text, x+12 yp w180 r8 section , %text%

  Loop %Button0%
    Gui %GuiID%:Add, Button, % ( A_Index=1 ? "x+12 ys " : "xp y+3 " ) . ( InStr( Button%A_Index%, "*" ) ? "Default " : " " ) . "w100 gCMsgButton", % RegExReplace( Button%A_Index%, "\*" )

  Gui %GuiID%:Show,,%title%

  Loop
    If( _CMsg_Result )
      Break

  If( owner <> 0 )
    Gui %owner%:-Disabled

  Gui %GuiID%:Destroy
  Result := _CMsg_Result
  _CMsg_Result := ""
  Return Result
}

9GuiEscape:
9GuiClose:
  _CMsg_Result := "Close"
Return

CMsgButton:
  StringReplace _CMsg_Result, A_GuiControl, &,, All
Return

A: The answer lies in syntax of your code. I highly suggest that you read the Tutorial in the Docs fully! It's really well written.
What immediately popped out to me is that your Variables in your If Expressions are surrounded by percents, which is wrong.
Here is a link to the section in the Tutorial that you need to read in order to fix your code.
Try this:
!o::
var := MsgBoxV2("Question11","Hi, what's up??","Sym|Go|C","24")
Msgbox 4,, You Pressed %var%

if (var = "C")
{
    Msgbox 4,, IT WORKED!
}

!e::
var := CMsgbox( "s", "d", "*&Sym|&Go|&C","",1 )
Msgbox 4,, You Pressed %var%

If (var = "C")
{
  Msgbox 4,, worked
}
return

The IfEqual command is pretty much deprecated and while it's still included in the latest releases, it's basically bad form to use since the If expression much easier to read. Also plain text excluding numbers in an expression should be surrounded by quotes. Hope this helps.


text:
Q: Basic book about mathematical proofs I'm looking for an understandable book about mathematical proofs.
As an engineer/computer scientist major I'm used to do higher math on a daily base, but whenever I'm asked in an exercise to "show" something I get the "where should I start? and what exactly do they want me to do?" syndrome.

A: There are books devoted to your question, e.g., Daniel Solow's book, How to Read and Do Proofs: An Introduction to Mathematical Thought Processes, http://www.wiley.com/WileyCDA/WileyTitle/productCd-EHEP000562.html but I'm not sure that's the way to go. It might be better to just pick up a good textbook in Number Theory (like Niven, Zuckerman, and Montgomery) or Abstract Algebra (like Fraleigh) or Discrete Math (maybe Grimaldi, or Brualdi), to see how people actually do proofs when they need them.

A: I just came across this physics forum with a thread on how to write mathematical proofs.  At first I was going to copy the list of texts there here, sorting out possible duplicates. But there are so many resources listed: books, tutorials, university-sponsored guides, etc. that I'll simply steer you to the site.

A: Read Pólya's How to Solve It. See also these slides.

A: You might also like this: How to Solve it: Modern Heuristics. I've read the first few pages and it's not bad at all.

A: There are many mathematics texts, ranging from the middle school level to the undergraduate level, that are designed, at least in part, to serve as an introduction to proof. I would recommend that you select a text of this nature about a mathematical or allied field that you find interesting.
Three examples, off the top of my head:

*

*Tom Apostol: Calculus, Volume I

*James Munkres: Topology

*Uhh … I can't find it right now, but there's an introductory real analysis text called something like Analysis that I used as a college freshman which is designed that way.

If you're into computer science, you could pick up a lot of proof techniques (and exercises) from Donald Knuth's The Art of Computer Programming, but that might be a bit on the intimidating side.
My introduction to proof came from my seventh grade geometry teacher, Darlyn Counihan, whose homework and tests consisted of nothing but proofs. Sadly, I hear that most geometry classes in the U.S. these days don't require students to write a single proof, which makes me wonder just what exactly such classes are for.

A: Perhaps you might like: Solving Mathematical Problems:
A Personal Perspective. By Terence Tao.

A: You can search for "thoughts - Alpha" this is a free downloadable online PDF book for mathematical proofs. the book is a compilation of proofs for basic mathematics (Trigonometric Identities, logarithms, basic series, volumes and surfaces, basic calculus)
Book's webpage:
http://thoughtsseries.weebly.com/
Author's scribd page:
https://www.scribd.com/user/295650299/Daniel-Benjamin-Rodriguez-Ortega

A: Writing proofs is essentially a sequence of statements and their justifications. We all learn some form of proof writing in geometry when we write two column proofs. With that being said, there are many techniques used in proof oriented problems.
There are many good books which have already been mentioned. I advise you not to touch Munkres unless you understand real analysis at the level of Baby Rudin.
Start with a simple intro: Appendix of Hungerford's undergrad Abstract Algebra.
Move onto first 10-15 pages of Baby Rudin to build your math background. Cover the beginning of chapter 2 in Baby Rudin.
Munkres Topology first 7 sections. The rest of the material requires much greater mathematical maturity.


text:
Q: CSS: horizontal position a popup at desired location I have this button, which when clicked displays a popup.
The popup is a div element with display:none to begin with. When the button is clicked, I set the display:block to show the popup.
The vertical location of the popup is just fine; right above the invoking button. However, I'm not able to position the downward arrow (speech bubble?) in the such a way that it appears over the centre of the invoking button.

*

*Can this be done with CSS?

*I'm ok with javascript solution too as long as I don't have to pull in a dependency.

*I'm ok with altering the structure of the html. The constraint that I have is both the popup and the button have to be in the same container. The button could be positioned anywhere in this container.

Perhaps a little code will help:
HTML:

    <input type="button" id="myButton" value="Click Me!">

        Sorry, I don't know :(

CSS:
#container {
    position: relative;
    top: 150px;
    left: 50px;
    width: 300px;
    text-align: right;
    background: tomato;
}

.sf-popup-panel {
    display: none;
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    width: 200px;
}

.sf-popup-panel.popup {
    top: auto;
    right: 0;
    bottom: 100%;
    left: auto;
}

.sf-popup-panel.open {
    display: block;
}

.sf-popup-panel.popup.open:before {
    position: absolute;
    display: block;
    content: " ";
    border: 14px solid transparent;
    border-top-color: #ccc;
    top: 100%;
    right: auto;
    left: 50%;
    width: 0px;
    margin-left: -1px;
}

.sf-popup-panel.open:after {
    position: absolute;
    display: block;
    content: " ";
    border: 13px solid transparent;
    border-top-color: white;
    top: 100%;
    right: auto;
    left: 50%;
    width: 0px;
}

.sf-su-response {
    padding: 15px;
}

JavaScript:
$('#myButton').click(function(){
    $(".sf-su-response").toggleClass("open");
});

JSFIDDLE
http://jsfiddle.net/Ru5aX/
EDIT:
Judging from the answers so far, perhaps, my question is not very clear.
Basically the button could be positioned anywhere in the parent div. I cannot make assumptions about it's position at design time. So solutions which set a right or left to specific values at design time would not work for me.
Of course, what would work is if i could somehow specify this popup to be positioned relative to the button; but, I don't know how :(
EDIT2
This is what I'm getting:

This is what I want:

A: Try changing as follows :-
.sf-popup-panel.popup {
        top: auto;
        right: -70px;
        bottom: 100%;
        left: auto;
    }

A: This should do the trick:
.sf-popup-panel.popup.open:before,.sf-popup-panel.open:after  {
  right: 40px;
}

Don't forget to remove left:50%.
fiddle

A: Try this one:
.sf-popup-panel {
    display: none;
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    width: 200px;
    margin-bottom:10px;
}

.sf-popup-panel.popup.open:before {
    position: absolute;
    display: block;
    content: " ";
    border: 14px solid transparent;
    border-top-color: #ccc;
    top: 100%;
    right: auto;
    left: 80%;
    width: 0px;
    margin-left: -1px;
}

.sf-popup-panel.open:after {
    position: absolute;
    display: block;
    content: " ";
    border: 13px solid transparent;
    border-top-color: white;
    top: 100%;
    right: auto;
    left: 80%;
    width: 0px;
}

A: So here's a solution for what you are asking.
http://jsfiddle.net/moellerb/vmUuc/
Explaination
Your "container" has a set width of 300px.  Since this is the parent element to your popup, the popup positions itself relative to that container's space.  In order to track the button 's position without heavy javascript, I would wrap the button and popup in another wrap container (.btn-wrap).  Set it to the button size in order to keep the containment size to the desired area of the button.

        <input type="button" id="myButton" value="Click Me!"/>

          Sorry, I don't know :(

Made a few adjustments to your popup-panel classes that display the pointer.  This will keep the pointer centered on the button and will keep the panel right justified like you requested in the example.
#btn-wrap {
    /* you could position it absolute, the popup will follow */
    position:relative;
    float:right;
    /* try any of these alternatives to float:right
    margin-left:100px;
    float:left;
    */

    /*Set the input/button container dimensions = button size*/
    width: 65px;
    height: 20px;
}

.sf-popup-panel.popup.open:before {
    ........
    ....
    right: 13px; /* set right instead of left */
    left: auto;
    width: 0px;
    margin-left: -1px;
}

.sf-popup-panel.open:after {
    ........
    ....
    right: 13px; /* set right instead of left */
    left: auto;
    width: 0px;
}


text:
Q: Placing values into variables perl I have a string like this
destination: 29231, 280646, 9.715e-2, 60, 109

and I'm trying to place each number into variables
if ($i =~ m/^destination:\s(\d+)\,\s(\d+)\,\s(\d+\.\d+\e-\d+)\,\s(\d+)\,\s(\d+)/){
$num1 = $1;
$num2 = $2;
$num3 = $3;
$num4 = $4;
$num5 = $5;
}

seems \s(\d+\.\d+\e-\d+)\ is not working, where am i doing wrong?

A: A better way of doing this is to use the split function. Here, you can split up the string into elements separated by spaces (\s+), and print them out (or rename them, or whatever) if they are digits (/^\d+/).
use strict;
use warnings;

my $string = 'destination: 29231, 280646, 9.715e-2, 60, 109';

my @split = split(/\s+/, $string);

foreach (@split){
    s/,//; # get rid of commas
    print "$_\n" if /^\d+/;
}

Prints:
29231
280646
9.715e-2
60
109

A: The solution depends on exactly how your strings are formatted, but you can just find all fields that aren't whitespace or comma and drop the first one, like this
use strict;
use warnings;

my $string = 'destination: 29231, 280646, 9.715e-2, 60, 109';

my @numbers = $string =~ /[^\s,]+/g;
shift @numbers;

print "$_\n" for @numbers;

output
29231
280646
9.715e-2
60
109

A: found it, just made mistake on \e,
correct expression should be this: \s(\d+\.\d+\w-\d+)\


text:
Q: Override global newtonsoft serialization options In my ASP.NET Core app, I have the following setup in Startup:
services.AddNewtonsoftJson(options =>
{
    options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
    options.SerializerSettings.DateFormatString = "yyyy/MM/dd"; // <-- HERE

});

The line marked with "HERE" comment sets a global way of handling DateTime serialization. This is what I need in 99% of the cases. However, I have an endpoint where I do not want to format dates this way and I want to retain time information as well (in ISO format for example). Is there any way to override the global setting somehow for specific endpoint or model?
I tried applying [JsonConverter(typeof(IsoDateTimeConverter))] attribute to my model's DateTime properties, but that didn't change anything.

A: It turned out I was applying the attribute wrong. I'm using records.
Instead of doing that:
public record Abc(
   [JsonConverter(typeof(IsoDateTimeConverter))]
   DateTime DateTime)

I should have done that:
public record Abc(
   [property: JsonConverter(typeof(IsoDateTimeConverter))]
   DateTime DateTime)

That way, the attribute gets applied to the property, and not constructor parameter. My record gets serialized with ISO time format, even though the global setting is different.


text:
Q: Using Camera2 API with ImageReader I'm trying to capture image data using the Camera2 API on a Galaxy S4.  ImageReader is being used as the surface provider.  The image format used has been tried with both ImageFormat.YV12 and ImageFormat.YUV_420_888 and produces the same results.
The setup seems fine, and I get an Image from the ImageReader using ImageReader.  The Image has 3 planes.  The buffers are the expected sizes, Width*Height for Y plane and (Width*Height)/4 for the other two planes.
The issue is that I'm not getting data properly in two ways.  The first issue is that the Y plane data is in mirror-image.  This can be dealt with, though it is strange so I am curious if this is expected.
The worse issue is that the other two planes don't seem to be delivering data correctly at all.  For instance, with an image size of 640x480, which results in U and V buffer sizes of 76800 bytes, only the first 320 bytes of the buffers are non-zero values.  This number varies and does not seem to follow a set ratio between different image sizes, but does seem to be consistent between images for each size.
I wonder if there is something that I am missing in using this API.  Code is below.
public class OnboardCamera {
  private final String TAG = "OnboardCamera";

  int mWidth = 1280;
  int mHeight = 720;
  int mYSize = mWidth*mHeight;
  int mUVSize = mYSize/4;
  int mFrameSize = mYSize+(mUVSize*2);

  //handler for the camera
  private HandlerThread mCameraHandlerThread;
  private Handler mCameraHandler;

  //the size of the ImageReader determines the output from the camera.
  private ImageReader mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.YV12, 30);

  private Surface mCameraRecieverSurface = mImageReader.getSurface();
  {
      mImageReader.setOnImageAvailableListener(mImageAvailListener, mCameraHandler);
  }

  private byte[] tempYbuffer = new byte[mYSize];
  private byte[] tempUbuffer = new byte[mUVSize];
  private byte[] tempVbuffer = new byte[mUVSize];

  ImageReader.OnImageAvailableListener mImageAvailListener = new ImageReader.OnImageAvailableListener() {
      @Override
      public void onImageAvailable(ImageReader reader) {
          //when a buffer is available from the camera
          //get the image
          Image image = reader.acquireNextImage();
          Image.Plane[] planes = image.getPlanes();

          //copy it into a byte[]
          byte[] outFrame = new byte[mFrameSize];
          int outFrameNextIndex = 0;

          ByteBuffer sourceBuffer = planes[0].getBuffer();
          sourceBuffer.get(tempYbuffer, 0, tempYbuffer.length);

          ByteBuffer vByteBuf = planes[1].getBuffer();
          vByteBuf.get(tempVbuffer);

          ByteBuffer yByteBuf = planes[2].getBuffer();
          yByteBuf.get(tempUbuffer);

          //free the Image
          image.close();
      }
  };

  OnboardCamera() {
      mCameraHandlerThread = new HandlerThread("mCameraHandlerThread");
      mCameraHandlerThread.start();
      mCameraHandler = new Handler(mCameraHandlerThread.getLooper());

  }

  @Override
  public boolean startProducing() {
      CameraManager cm = (CameraManager) Ten8Application.getAppContext().getSystemService(Context.CAMERA_SERVICE);
      try {
          String[] cameraList = cm.getCameraIdList();
          for (String cd: cameraList) {
              //get camera characteristics
              CameraCharacteristics mCameraCharacteristics = cm.getCameraCharacteristics(cd);

              //check if the camera is in the back - if not, continue to next
              if (mCameraCharacteristics.get(CameraCharacteristics.LENS_FACING) != CameraCharacteristics.LENS_FACING_BACK) {
                  continue;
              }

              //get StreamConfigurationMap - supported image formats
              StreamConfigurationMap scm = mCameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

              android.util.Size[] sizes =  scm.getOutputSizes(ImageFormat.YV12);

              cm.openCamera(cd, mDeviceStateCallback, mCameraHandler);
          }

      } catch (CameraAccessException e) {
          e.printStackTrace();
          Log.e(TAG, "CameraAccessException detected", e);
      }
      return false;
  }

  private final CameraDevice.StateCallback mDeviceStateCallback = new CameraDevice.StateCallback() {
      @Override
      public void onOpened(CameraDevice camera) {
          //make list of surfaces to give to camera
          List<Surface> surfaceList = new ArrayList<>();
          surfaceList.add(mCameraRecieverSurface);

          try {
              camera.createCaptureSession(surfaceList, mCaptureSessionStateCallback, mCameraHandler);
          } catch (CameraAccessException e) {
              Log.e(TAG, "createCaptureSession threw CameraAccessException.", e);
          }
      }

      @Override
      public void onDisconnected(CameraDevice camera) {

      }

      @Override
      public void onError(CameraDevice camera, int error) {

      }
  };

  private final CameraCaptureSession.StateCallback mCaptureSessionStateCallback = new CameraCaptureSession.StateCallback() {
      @Override
      public void onConfigured(CameraCaptureSession session) {
          try {
              CaptureRequest.Builder requestBuilder = session.getDevice().createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
              requestBuilder.addTarget(mCameraRecieverSurface);
              //set to null - image data will be produced but will not receive metadata
              session.setRepeatingRequest(requestBuilder.build(), null, mCameraHandler);

          } catch (CameraAccessException e) {
              Log.e(TAG, "createCaptureSession threw CameraAccessException.", e);
          }

      }

      @Override
      public void onConfigureFailed(CameraCaptureSession session) {

      }
  };
}

A: I had the same issue, the problem I believe was in Android API 21. I upgraded to API 23 and the same code worked fine. Also tested on API 22 and it also worked.

A: Are you paying attention to the Image.Plane's row- and pixelStride parameters?
Due to hardware memory mapping constraints, the row stride is often larger than the width of the image, and the start of row y in the image is at position (yrowStride) instead of (ywidth) in the ByteArray for a given plane.
If that's the case, it's not surprising that after the first 320 bytes for a 640x480 image (1 row of subsampled chroma data), the U or V plane will be 0 for some time - there should be (rowStride - width) bytes of zeros or garbage, and then the next row of pixel data will start.
Note that if pixelStride is not 1, then you also have to skip bytes between pixel values; this is most often used when the underlying YCbCr buffer is actually semi-planar, not planar.


text:
Q: KeyGesture not accepting a Shift+Alphanumeric key combination I'm attempting to execute some WPF commands with help of WPF KeyGesture class. Application works fine until I specify a key combination consisting of Shift modifier and an alphanumeric key. For example, following instantiation: new KeyGesture(Key.M, ModifierKeys.Shift) throws an exception:

'Shift+M' key and modifier combination is not supported for KeyGesture.

Bare Shift modifier won't work with numbers too (e.g. Shift + 2). However, Shift + Insert or Shift + F1 combinations work flawlessly. Just to put it clear, there are no problems with Shift + Ctrl, Shift + Alt or Alt + 1 and alike.
Why was a decision made to forbid Shift + [Alphanumeric] gesture? Does it have anything in common with typing capital letters? Is there a workaround coherent with the WPF commanding system?
(Note: I'm not trying to use a Shift + M gesture, while filling textboxes, but rather when no textbox is in focus.)
I seem to find only one forum entry, where this issue is raised. A documentation search failed. Is it so obvious for developers to avoid Shift + [Alphanumeric]?

A: See SO 8251043 - basically it's no longer a "gesture" its a keybinding
Create a simple, unmodified key binding in WPF


text:
Q: how can I change allowed file type in codignetor which actually work? Here is my controller code but only jpg and png file are uploaded I also changed it my process model.php also.
Is there any way to change it? And it doesn't show any warning. You can check it from here but you need to register first...
public function saveTestimonial() {
  $config['upload_path'] = './testimonial_photo/';
  $config['allowed_types'] = 'gif|jpg|png|psd|zip|tif|ai|eps';
  $config['max_size'] = '1024';
  $config['max_width'] = '10240';
  $config['max_height'] = '7680';

A: You should declare file upload like the below code. Since you are uploading images, docx, zip files you should not declare max_width and max_height. But you can change the max_size for the file.
    $config['upload_path'] = 'testimonial_photo/';
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
    $this->upload->set_allowed_types('gif|jpg|png|jpeg|zip|pdf|doc|docx');
    $this->upload->do_upload('filename_in_html_input')


text:
Q: Lenovo g510 webcam not detected I have lenvo g510. Cheese and guvcview don't detect my webcam.
Its my lsubs:
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

How to fix it?

A: I was having the exact same issue on my 1 day old Lenovo G510.  At first the webcam was detected and working fine.  One time it stopped working; I rebooted and it was fine again.
Then a few hours later it stopped again and rebooting did nothing. I got the identical results as you from lsusb - the webcam is not listed.
This morning I tried plugging in an old USB webcam and as soon as I did, the integrated webcam was recognized and work with all apps.  I had plugged the USB cam into the USB 2 port on the right side near the power. Here is my current lsusb results:
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 003 Device 004: ID 0cf3:3004 Atheros Communications, Inc.
Bus 003 Device 003: ID 04f2:b3bb Chicony Electronics Co., Ltd
Bus 003 Device 002: ID 04fc:05da Sunplus Technology Co., Ltd
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The Sunplus is a wireless mouse.  The Chicony is the webcam, but notice also the Atheros which seems to be the bluetooth. Both of these are missing in the lsusb you posted and were missing in mine as well. I had my bluetooth turned off, but at some point in this process is was turned on again - not sure how or when.
I would turn your bluetooth on/off and plug some USB devices in - see what happens cause it worked for me.  If anyone has insight as to why the above worked I'd love to hear.

A: @Aaron R. - Your answer doesn't work. This is how I made my webcam (G510) work:
useradd -G video username
That's it. Reboot!


text:
Q: ios Push notification not showing up in App I am trying to set up push notifications in my iOS7 app and am running into issues.
Basically the push never shows up I when through the process of creating the certificates and the provisioning profiles. Currently I only have it built for development and will get the distribution one made up when I am ready to submit it. But in the development setup everything appears to be correct. I made a PHP file to create the message in dictionary format and I believe everything is correct on that side of things. The passthru code is addedd correctly and I connect to the APNS server correctly (the development side) I can tell this because when I make my pass code incorrect it does fail.
From going through the iOS development documents related to PUSH I added a persistantConnection profile onto my phone and view the detailed log files and according to that data it should also be working.
I am not totally familiar with reading this data but the good things I was told to look for were there and the bad things were not.
I will attach my PHP script and the log from the device
PHP script

session_start();
if($_POST['message']){

$deviceToken = array();

$deviceToken[0]="xxxx3ee0 3xxxx973 6bxxxxea 2843xxxx dx5xbx1x x4x8x0xe 7xx65xx9 x61xx01x";

$payload ='{
                "aps" :

                    {   "alert" : "'.$_POST['message'].'"
                        , "badge" : 1
                        , "sound" : "bingbong.aiff"
                    }
            }';

/*
$payload = '
{
    "aps": {
        "alert": "alert",
        "sound": "default"
    },
    "message": "'.$_POST['message'].'",
    "id": 1234
}
';

*/
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'ck.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($streamContext, 'ssl', 'passphrase', "xoxoxoxo");

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);

if(!$apns) {
    print"Stream failed to create ". $error. " ".$errorString;
    return;
} else {
    print"Message Sent";
}

foreach($deviceToken as $key=>$value){

    $apnsMessage = chr(0) . pack("n",32) . pack('H*',str_replace(' ', '', $value)) . pack ("n", strlen($payload)) . $payload;
   // $apnsMessage = chr(0) . chr(0) . chr(32) . @pack('H*', str_replace(' ', '', $value)) . chr(0) . chr(strlen($payload)) . $payload;
    fwrite($apns, $apnsMessage);
    print "<BR>Message Delivered - ". $payload;
}
fclose($apns);
}
?>
<form action="blanket.php" method="post">
<input type="text" placeholder="message" name="message">
<input type="submit" value="submit">
</form>

According to the doc this is what I am looking for
I see this:
Look for messages from the apsd process. Ideally you'll see Connected to courier x-courier.sandbox.push.apple.com where x is a small integer. That indicates that the device has successfully established its persistent connection to the push service.
I do not see this:
You might on the other hand see Disconnecting in response to connection failure. That means that the persistent connection failed. In that case, the goal is to figure out what's going on with your network that's causing the connection failure. Check that no firewalls are blocking TCP traffic on port 5223.
I do not see this:
The message connection set ignored topics means that the user chose to turn off notifications for the apps listed in the message. That will be followed by Sending filter message for enabled hashes which is where iOS actually sends the enabled and ignored topics to APNs.
I do not see this:
The message Failed to parse JSON message payload indicates that the JSON dictionary in the notification payload is not in valid JSON format.
The bad part is I also do not see this:
The message Received message for enabled topic  means that the device received a notification from the push service.
DATA FROM LOG search for this criteria "Connected to Courier"
showing good info
2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16e49ff0> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference NonCellular shouldUseDualChannel YES. Connected on 1 interfaces.
2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16d78f70> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference NonCellular shouldUseDualChannel YES. Connected on 1 interfaces.
2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Connected to courier 2-courier.sandbox.push.apple.com (17.149.34.142) connection: <APSCourierConnection: 0x16d79810> onInterface: NonCellular
2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Connected to courier 30-courier.push.apple.com (17.149.36.134) connection: <APSCourierConnection: 0x16d4a380> onInterface: NonCellular
2014-03-14 14:56:55 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for PushConnectionConnected
2014-03-14 14:56:55 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for PushConnectionConnected
2014-03-14 14:57:52 -0700 apsd[83]: <APSCourier: 0x16d78f70> - systemDidLock and we're connected via noncellular, sending inactive ping to the server
2014-03-14 14:57:52 -0700 apsd[83]: <APSCourier: 0x16e49ff0> - systemDidLock and we're connected via noncellular, sending inactive ping to the server
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourierConnection: 0x16d4a380> WWAN is connected; to be consistent, closing the non-cellular connection
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> courierConnection <APSCourierConnection: 0x16d4a380> asked us to disconnect stream on interface NonCellular. Connected on 2 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for ConnectionDisconnected
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> courierConnection <APSCourierConnection: 0x16d4a380> asked us to disconnect stream on interface NonCellular. Connected on 1 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for ConnectionDisconnected
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference None shouldUseDualChannel NO. Connected on 1 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> _connectStream - caller is ensuring that we are connected. We are so there's nothing to do here. - Connected on 1 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourierConnection: 0x16d79810> WWAN is connected; to be consistent, closing the non-cellular connection
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> courierConnection <APSCourierConnection: 0x16d79810> asked us to disconnect stream on interface NonCellular. Connected on 2 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for ConnectionDisconnected
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> courierConnection <APSCourierConnection: 0x16d79810> asked us to disconnect stream on interface NonCellular. Connected on 1 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for ConnectionDisconnected
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference None shouldUseDualChannel NO. Connected on 1 interfaces.
2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> _connectStream - caller is ensuring that we are connected. We are so there's nothing to do here. - Connected on 1 interfaces.

As far as I can tell it should be working but it is not.
Any ideas?

A: Can you try to remove the white space between the device token so that your device token will look like
$deviceToken[0]="xxxx3ee03xxxx9736bxxxxea2843xxxxdx5xbx1xx4x8x0xe7xx65xx9x61xx01x";

As per my knowedge , device token should not contain any white space & symbols < , >
Also check the return code from request & feedback service to give you information about failed push notifications as mentioned here
Please let me know if it works


text:
Q: How to keep rows of a data frame which appear in another data frame in R? country <- c("Afghanistan", "Afghanistan", "Brazil", "Brazil", "China", "China")
year <- c(2012, 2013, 2012, 2013, 2012, 2013)
var1 <- c(10,12,43,55,99,53)
df_panel <- cbind.data.frame(country, year, var1)

country_list <- c("Afghanistan", "China")

df_panel contains information for several countries across multiple years for several variables, while country_list contains the list of all countries which should appear in the dataset. How do I remove those countries from df_panel which do not appear in country_list.
Thank you.

A: We can use subset with %in%
 subset(df_panel, country %in% country_list)


text:
Q: Samba share / Window host / Ubuntu Guest here is samba share lines Permissions for folder here.I have tried searching for an answer but cannot find one I understand. I have a desktop with Window 10 OS and Ubuntu in a VM. Using virtualbox I am sharing two folders on my Windows host with my Ubuntu vm. I can view/create/delete files and folders on my shared folders using the Ubuntu vm.
I decided to try and learn something about file sharing. I created a samba share in Ubuntu to use with my Windows OS. I can view and create folders from Windows into my Ubuntu samba shares but I cannot delete them from Windows. I can ssh in and delete the folders I create from Windows. I can delete them in Ubuntu but I cannot delete them from Windows file explorer.
I made the samba shares because I want my movie collection available to others in my house without them having to install Plex or something like that. I can watch movies using my VLC app on my laptop this way.
I also wanted to learn how to have a network share etc.
Why can I delete folders on my samba share from a Windows command line but not from file explorer?

A: First of all Welcome to AskUbuntu.
You're fighting with linux permissions.
By default in samba share you can create files from clients, but you don't have permission to delete them.
When you create a file from a client i.e.(windows) in your samba share, it's created with mask 0644, but the client is not the owner of the directory, so you can't delete it.
First of all create a specific user here I use sambashare but you can customize it.
sudo adduser --system sambashare

Create a mount point
sudo mkdir /mnt/MyStuff

Change owner of share directory
sudo chown -R sambashare:sambashare /mnt/MyStuff

Change directory permissions to 755
sudo chmod 755 /mnt/MyStuff

Then simple force samba to use user sambashare
[MyStuff]
path = /mnt/MyStuff
writeable = yes
browseable = yes
read only = no
public = yes
create mask = 2755
directory mask = 2755
force user = sambashare

Then restart samba
sudo systemctl restart smbd

Found uid and gid of created user using
cat /etc/passwd | grep sambashare

gives sambashare:x:122:65534::/home/sambashare:/usr/sbin/nologin
cat /etc/group | grep sambashare

gives sambashare:x:122:cube
According to output uid and gid are 122
Edit /etc/fstab to add entry for the mount point using correct uig and gid
MyStuff    /mnt/MyStuff  vboxsf  uid=122,gid=122,umask=0022 0 0

Note MyStuff is the name you provide when you create shared directory under virtualbox.
Now add the module vboxsf to /etc/modules to force module loading onboot.
In VirtualBox application remove the option automount.
Then Reboot. Now you should be able to create/delete files in your shared directory from windows.


text:
Q: Select columns in list and replace it with names number<-list(matrix(1:6,2,3),matrix(2:7,2,3))
fruit<-c("apple","banana","pear","orange","berry","grape","watermelon")

Aim: Select the first two columns of the list "number", and then replace related number with the name in "fruit".
My code is as follows.
result<-lapply(number,function(a) {fruit[a[,c(1,2)]]})

But the result is not what I want.
[[1]]
[1] "apple"  "banana" "pear"   "orange"

[[2]]
[1] "banana" "pear"   "orange" "berry"

while my expected result is as follows;
[[1]]
[1] "apple"     "pear"
[2] "banana"  "orange"

[[2]]
[1] "banana"  "orange"
[2]   "pear"   "berry"

Could you help me with this, thanks!

A: It's giving you the right answer, but it vectorizes your matrix.  Try:
result <- lapply(number,function(a) {matrix(fruit[a[,c(1,2)]],nrow=nrow(a))})


text:
Q: Want to display two string value in two different tkinter label I make code for displaying two serial read string in two different label using tkinter GUI..
My code is running and window also popped up but values are not displaying..
Help me to solve this issue..
Here is my code

import serial
import tkinter
from tkinter import *
import time
class SerialViewer(Tk):
 def _init_(self):
      self.win = Tk()
      self.ser=serial.Serial('/dev/ttyS0',9600)
 def makewindow (self):
      frame1 =Frame(self.win)
      frame1.pack()
      self.v=StringVar()
      self.v.set=('default')
      label=Label(frame1,textvariable=self.v,relief=RAISED)
      label.pack(side=LEFT)
      frame2 = Frame(self.win)
      frame2.pack()
      self.d=StringVar()
      self.d.set=('default')
      label=Label(frame2,textvariable=self.d,relief=RAISED)
      label.pack(side=RIGHT)
 def update(self):
       print(self.ser.write("*01T%"))
       data=self.ser.readline(self.ser.inWaiting())
       self.v.set(data)
       time.sleep(2)
       print(self.ser.write('*00T%'))
       data1=self.ser.readline(self.ser.inWaiting())
       self.d.set(data1)
       self.win.after(100,self.update)
 def run (self):
       self.makewindow()
       self.update()
       self.win.mainloop()
app=SerialViewer()
app.mainloop()

A: As said in comment that the method _init_ needs to be changed to __init__ and the recursion error is coming because the __init__ method of parent class wasn't called. Please add that call like below:
class SerialViewer(Tk):
    def _init_(self):
        super(SerialViewer, self).__init__() # Call the initializer method of parent class
        self.win = Tk()
        self.ser=serial.Serial('/dev/ttyS0',9600)

Hope this helps!!


text:
Q: Attractors and solutions to these generalized Ornstein–Uhlenbeck processes? This is a question about generalized Ornstein–Uhlenbeck processes I asked on MSE, but I haven't received replies about their attractors and solutions yet. So I would appreciate if someone could give me at least some hints. Thanks a lot!
An Ornstein–Uhlenbeck process is
$$
d X_t =  (\mu - X_t) dt + d W_t
$$
We try to build a model using some generalized Ornstein–Uhlenbeck processes.

*

*The first one is
$$
d X_t =  \exp(-|X_t- \mu|) (\mu - X_t) dt + d W_t
$$
where we hope $\exp(-|X_t- \mu|)$ will reduce the speed of $X_t$ approaching  $\mu$, as $X_t$ comes closer to $\mu$.

*Furthermore, since an O-U sde has a attractor $\mu$, we tempt to generalize the above sde to have more than one attractors
$$
d X_t = \sum_{i=1}^3 \exp(-|X_t- \mu_i|) (\mu_i - X_t) dt + d W_t
$$
I have little idea about these two generalized Ornstein–Uhlenbeck processes.
So may I ask here if there are some references on them?
Do they have weak or strong solutions and how to determine their solutions?
How are their attraction regions like and decided?
Thanks in advance!


text:
Q: Looking for differential operators satisfying a specific commutation relation with the Laplace operator Consider the Laplace operator on some manifold, $\Delta=(\det g)^{-1/2} \frac{\partial}{\partial x^j} \left( (\det g)^{1/2}g^{jk} \frac{\partial}{\partial x^k}\right) $.
I am looking for differential operators $Q$ satisfying the following relationship with the Laplace operator,
$$ [ \Delta, Q]f = \Delta (Qf) - Q \Delta f = \omega Q f~,$$
where the first equality sign serves as a definition, $\omega$ is a non-zero real number, and $f$ is a test function. Have these operators $Q$ been studied before in the literature? If so, does an explicit expression exist for such operators?
Perhaps it is worth mentioning that I am particularly interested in the above question for the Laplacian on the Poincaré disk,
$$\Delta = \frac{1}{4}(1-x^2-y^2)(\partial_x^2+\partial_y^2)~.$$
Any help with either the general case or the specific case of the Poincaré disk is most welcome.
NOTE: I asked the same question in the math stack exchange but, perhaps due to the `physics phrasing', did not receive any response so far. For this reason and because of the fact that this question is also relevant for physics, I decided to ask it here as well.


text:
Q: Why does a call to Model.create!() return when the mysql transaction hasn't completed? I watched a video where their signup page was causing issues because the call to:
person = Person.create!(params)

returns when in fact mysql hasn't necessarily completed the transaction yet.
Why would it return before the transaction?
video: http://cdn.confreaks.com/system/assets/datas/5097/original/1119-gogaruco2012-services-scale-backgrounding-and-wtf-is-going-on-here-small.mp4?1349207263

A: i did not watch the video, but from what i know about transactions, calling create or find or whatever, is not within any transaction!
you need to define transactions in the code yourself:
Person.transaction do
   [...]
end

here are some nice examples of how to work with transactions in rails: http://markdaggett.com/blog/2011/12/01/transactions-in-rails/


text:
Q: Java continuous console while running Recently I have been making a little java game where you build up a city and have to defend it. Now I want to make it ready for proper testing. I was thinking of having the server running on an old computer of mine, than I would have to make it so that, while the program is running, I can type in commands that will be executed. Like the minecraft or craftbukkit servers have. There you can type in text and press enter in the same console as where you started the program.
Anybody got any ideas?

A: Sounds like you just need a Scanner object.
For example, to continuously wait for input and then print that input, you would write:
Scanner s = new Scanner(System.in);
String foo = s.nextLine();
System.out.println(foo);

System.in as the constructor parameter specifies that you are reading input from the keyboard (as opposed to a file, for example).


text:
Q: listings caption is distorted I used listing for listing the codes like:
\documentclass[prodmode,acmtecs]{acmsmall}

% Package to generate and customize Algorithm as per ACM style
\usepackage[ruled]{algorithm2e}
\usepackage{listings}
\usepackage{array}
\renewcommand{\algorithmcfname}{ALGORITHM}
\SetAlFnt{\small}
\SetAlCapFnt{\small}
\SetAlCapNameFnt{\small}
\SetAlCapHSkip{0pt}
\IncMargin{-\parindent}

% Document starts
\begin{document}

% Title portion
\title{Some title}
\author{Some Author
\affil{Some University}}
\maketitle
\lstset{
    frame=tblr
    }

\begin{lstlisting}[caption = video tag in HTML5]
<video id=``movie" width=``640" height=``480">
</video>
\end{lstlisting}
\end{document}

But I am not getting listings caption in a single line. It displays caption like
Listing 1.
video
tag
in
HTML5

I think the caption width is somehow minimized. Any idea about how I could fix this problem?

A: I don't know if this has adverse effects on other parts of the document, but saying
\AtBeginDocument{\setlength{\tempdimen}{\textwidth}}

seems to solve the issue.
The acmsmall class uses \tempdimen to set the captions, but the captions built by listings don't set it to a sensible value and so use the default (which is zero).


text:
Q: Installing CDT plugin to eclipse kepler in windows I tried to install cdt plugin to eclipse kepler through install new software. There are many sites to do so. But that is not accessible. Please help me!

A: You can always download a complete "Eclipse IDE for C/C++ Developers" release which already has the CDT built in from this download link


text:
Q: Dynamical horizontal content views I'm completely new on React and i want to check out, if my idea is possible.
I want to create an website with following layout:

The green side is an collapsible navigation. On the sample screen, the navigation is showing. If an user want to hide the navigation, these will be toggled (like bootstrap navigations) with an smaller width.
The content will be stretched to the rest of complete width.
If you click on an link (depend on which link), a new view will be inserted on the left or right side on the content (see exmaples). The maximum of "Subviews" is 3.

Is these layout possible?
I want lot's of ideas and food for thought!

A: Yes, it is possible. You want to look into flexbox and how it works in RN and also you can take a look at react-native-navigation (wix), which provides both the left and right drawer.
If you want to do it yourself, basically you want to do something like this (haven't test it):
<View style={{flexDirection: "row"}}>
<View style={{flex: 0.3, backgroundColor: "green"}}/>
<View style={{flex: 0.15, backgroundColor: "brown"}}/>
<View style={{flex: 1, backgroundColor: "silver"}}/>
<View style={{flex: 0.15, backgroundColor: "black"}}/>
</View>

Now, flexDirection makes the children be aligned horizontally, then the flex is basically the variable dimensions the view should cover. You can use dp or percentage here as well.
The third one has a flex of 1, meaning that it will tell RN to use as much space as possible to cover the remaining space.
In order to hide or show a particular view you can either animate them or set the style and modify the flex.
Hope it helps


text:
Q: Is there a better method than mapping str to float then mapping to int? I need to merge two data frames. In df_A the key is an int. In df_B the key is a string ending in .0 e.g. '10003.0'.
I would like to convert the string in df_B to an int for merging. Is there a better way than mapping twice as seen below?
df_B['key'].map(float).map(int)

The syntax seems awkward to me. Is there a better solution?

A: You can using to_numeric
pd.to_numeric(df_B['key'],downcast='integer')


text:
Q: How can I match any character BUT a string with POSIX Extended Regex (for sed)? I am dealing with a string:
Input File
----
some**wor*ds**with**asterisks

By telling sed to match any character that is not an asterisk:
echo "some**words** **" | sed -E 's/\*\*([^*]+)\*\*/FOO\1FOO/g'

This shall properly output: someFOOwordsFOO **
But this would not work with the above Input File.
I should therefore like to tell sed to ignore two subsequent asterisks.
sed -E 's/\*\*([^*]+)\*\*/FOO\1FOO}/g' IF

would output:
some**wor*dsFOOwithFOOasterisks

Where what I should like is:
someFOOwor*dsFOOwith**asterisks

A: Using Perl with a non-greedy capturing of the word:
$ echo 'some**wor*ds**with**asterisks' | perl -pe 's/\*\*(.*?)\*\*/FOO$1FOO/'
someFOOwor*dsFOOwith**asterisks

This matches from the first ** to the next closest ** and replaces that matching bit by FOO, the substring between the two **, and then FOO again.  Without the non-greedy matching, the second ** in the expression would match the last such string on the line, after with.
Using sed:
$ echo 'some**wor*ds**with**asterisks' | sed '/\*\*.*\*\*/ { s/\*\*/FOO/; s//FOO/; }'
someFOOwor*dsFOOwith**asterisks

This replaces the first ** on the line with FOO and then the next one too, but only if the line contains ** followed by another **.
Note that we don't care about what substring of the line the two ** are flanking, only that a ** is matched with the next closest **.  This goes for both commands above.

Looking at the example in the comments:
some**wor*ds**with**asterisks some**wor*ds**with**asterisks

This can be handled with an explicit loop in sed that iterates over the already given solution until there are nothing more to do:
sed -e ':again' -e '/\*\*.*\*\*/ { s/\*\*/FOO/; s//FOO/; b again; }'

The Perl variant can be made to work on repeated instances of the pattern by just adding the g flag to the substitution:
perl -pe 's/\*\*(.*?)\*\*/FOO$1FOO/g'


text:
Q: Why do we define the Brownian motion asociated to a Filtration? In every book that I've seen, the authors define the Brownian motion with respect to a probability space $(\Omega, \mathcal{F}, \mathbb{P})$ where $\mathcal{F}$ is a filtration. Also, I have seen that the natural filtration induces a brownian motion and that every filtration can be extended to one with usual conditions.
So I want to know what's the role of the filtration when defining the Brownian motion. Why do we need/use it?

A: Filtrations keep track of information and the information available to us is not always the information generated by a particular Brownian motion.
For example, let's suppose that $W_t$ is a Brownian motion and $\mathcal{F}_t^W = \sigma(W_s : s \leq t)$ is its natural filtration. This encodes the information we get by observing the Brownian motion. What happens to the process $W$ if we are told the value of $W_1$? This changes the information available to us at time $t \leq 1$ to be $\mathcal{G}_t = \mathcal{F}_t \vee \sigma(W_1)$ (i.e. the $\sigma$ algebra generated by $\mathcal{F}_t$ and $W_1$).
The process $W_t$ has a semi-martingale decomposition with respect to the filtration $\mathcal{G}_t$ given for $t<1$ by (see Section 2.2.1)
$$
W_t = \underbrace{W_t - \int_0^t \frac{W_1 - W_s}{1-s}ds}_{B_t} + \int_0^t\frac{W_1-W_s}{1-s}
$$
where $B_t$ is $\mathcal{G}_t$ Brownian motion for $t \leq 1$. This is one way (in my mind the "right way") of constructing the Brownian Bridge.
The point here is that $W_t$ and $B_t$ are both Brownian motions, but in different filtrations, where different pieces of information are available to us. Clearly, though, $W_t$ is not $\mathcal{G}_t$ Brownian motion (and it shouldn't be! We know its value at time $1$ in $\mathcal{G}_t$!) and so the property of "being Brownian Motion" is always with reference to some filtration.
You might now be wondering why we don't just throw away $\mathcal{G}_t$ when studying the $B$ above and work with its natural filtration. A good reason is that if we did so, we would throw away an important piece of information, namely that $\sigma(W_1) \subset \mathcal{G}_0$, which implies by Blumenthal's 0-1 law (really it's just the Markov property plus the fact that $B_0 =0$) that $B$ is independent of $W_1$. This means among other things that in the SDE describing $W$ in $\mathcal{G}_t$, we can treat $W_1$ as a constant. The fact that $B$ is independent of $W_1$ is a key observation if you want to rigorously show that it makes sense to say that the law of the Brownian motion $W$ conditioned on $W_1 = 0$ is given by the SDE
$$
dW_t = \frac{-W_t}{1-t}dt + dB_t \\
W_0 = 0
$$
which you will often see as a definition of the Brownian Bridge.


text:
Q: Cannot resolve reference to bean 'DefaultSecurityFilterChain#0' Hello im getting this error, my spring-security is:
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.2.xsd">

     <global-method-security pre-post-annotations="enabled" />
    <http auto-config="true"
        use-expressions ="true"
        access-denied-page="/AccesoDenegado.xhtml">

    <!-- Se definen los dos perfiles y se interceptan las paginas para realizar la autenticacion -->

        <intercept-url pattern="/page1**" access="ROLE_PROFE"/>

        <intercept-url pattern="/page2**" access="ROLE_ALUMNO" />

         <!--Se define una pagina de login personalizada, no a que viene por defecto-->

         <form-login
         login-processing-url="/j_spring_security_check"
         login-page="/login.xhtml"
         authentication-failure-url="/login" />

          <!-- Cerrar Sesion-->

          <logout invalidate-session="true" delete-cookies="JSESSIONID" logout-success-url="/" logout-url="/logout" />

    </http>

   <!--Autenticación de uuarios de la BBDD-->
    <authentication-manager>

      <authentication-provider>

        <jdbc-user-service data-source-ref="dataSource"
          users-by-username-query=
            "select usuario,contraseña, habilitado from tabla_usuarios where usuario=?"
          authorities-by-username-query=
            "select usuario, rol from roles where usuario =?  " />

      </authentication-provider>
    </authentication-manager>

my Aplication Context
    <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 <!-- Alumno -->
    <!-- Database Configuration -->

    <import resource="classes/com/mkyong/customer/spring/DataSource.xml"/>
    <import resource="classes/com/mkyong/customer/spring/HibernateSessionFactory.xml"/>

    <!-- Beans Declaration -->
    <import resource="classes/com/mkyong/customer/spring/CustomerBean.xml"/>

</beans>

My hibernate session factory
 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- Hibernate session factory -->

<bean id="sessionFactory"
     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

    <property name="dataSource">
      <ref bean="dataSource"/>
    </property>

    <property name="hibernateProperties">
       <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         <prop key="hibernate.show_sql">true</prop>
       </props>
    </property>

    <property name="mappingResources">
    <list>
          <value>com/mkyong/customer/hibernate/Customer.hbm.xml</value>
    </list>
     </property>

</bean>
</beans>

my dataSource bean
 <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 <bean
   class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="location">
     <value>WEB-INF/classes/config/database/db.properties</value>
   </property>
</bean>

  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
  </bean>

</beans>

and my customer bean
    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="customerBo"
         class="customer.bo.impl.CustomerBoImpl" >
        <property name="customerDao" ref="customerDao" />
    </bean>

    <bean id="customerDao"
         class="customer.dao.impl.CustomerDaoImpl" >
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

</beans>

when i use autentication without hibernate works fine, but when i integrate them, i get that error.. any idea why??
My web.xml
    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>Spring MVC Application</display-name>

   <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
           /WEB-INF/spring-security.xml
    </param-value>
  </context-param>

  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
  </listener>

  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>home.xhtml</welcome-file>
  </welcome-file-list>
</web-app>

Stacktrace
ago 02, 2014 5:34:23 AM org.springframework.web.context.ContextLoader initWebApplicationContext
Grave: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:350)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:670)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:350)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:631)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1075)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:979)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
    ... 44 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:631)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1075)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:979)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
    ... 54 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1468)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
    ... 66 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:350)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:631)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1075)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:979)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

A: The (end of) last error message in your stacktrace is explicit :
Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined

You have <jdbc-user-service data-source-ref="dataSource" in your spring-security.xml
I assume the table usuario exists in the database loaded with classes/com/mkyong/customer/spring/DataSource.xml" through the import from main application context.
In your web.xml, you load correctly spring-security.xml but I can see no reference to another root application context.
So either you forgot to load main application context in main contextConfigLocation bloc of your web.xml, or you tried to load it as the context of mvc-dispatcher servlet. That is incorrect : beans in servlet application context can refer to beans in main context, the not the inverse.
To fix your error, load anything that is not directly related to the servlet (the database and the dao) in the root application context, ie in the <contextparam> bloc. mvc-dispatcher-servlet.xml should only contain view resolvers, controllers, interceptors, form beans or other only related to the view or controller layer, but neither the service layer nor the persistence layer.


text:
Q: Is there any library for Shift JIS encoding on Silverlight? Is there any library that can be used to decode Shift JIS text on Silverlight?

A: I was able to port Mono's implementation to .NET in less than an hour. This is the (minimal?) set of classes that needs to be ported (sorted by dependency):

*

*I18N.Common.Strings

*I18N.Common.MonoEncoding

*I18N.CJK.CodeTable

*I18N.CJK.DbcsConvert

*I18N.CJK.DbcsEncoding

*I18N.CJK.JISConvert

*I18N.CJK.CP932
Additionally, the following file needs to be copied (loaded in the constructor of I18N.CJK.CodeTable):

*

*jis.table
The class that implements the "shift_jis" encoding is I18N.CJK.CP932. Note that it must be instantiated manually, not through Encoding.GetEncoding().

A: I found some info here:
http://www.eggheadcafe.com/community/aspnet/14/14621/covert-shiftjis-to-unicode.aspx
This is the sample C# code from the link above (credits to Peter Bromberg). I cannot say for sure that it will work in Silverlight. I suppose it all depends on whether Encoding.GetEncoding("shift-jis") is available in SL:
public class FileConverter
{
    const int BufferSize = 8096;

    public static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine
                ("Usage: FileConverter <input file> <output file>");
            return;
        }
        //NOTE: you may need to use " Encoding enc = Encoding.GetEncoding("shift-jis"); " for non-standard code pages
        // Open a TextReader for the appropriate file
        using (TextReader input = new StreamReader
               (new FileStream (args[0], FileMode.Open),
                Encoding.UTF8))
        {
            // Open a TextWriter for the appropriate file
            using (TextWriter output = new StreamWriter
                   (new FileStream (args[1], FileMode.Create),
                    Encoding.Unicode))
            {

                // Create the buffer
                char[] buffer = new char[BufferSize];
                int len;

                // Repeatedly copy data until we've finished
                while ( (len = input.Read (buffer, 0, BufferSize)) > 0)
                {
                    output.Write (buffer, 0, len);
                }
            }
        }
    }
}


text:
Q: What is the difference between Float and float in java? Can someone explain to me the difference between Float and float in java? Manythanks.

A: Float is a class which wraps the primitive float.  In newer versions of Java, a feature called autoboxing makes it hard to tell that they are different but generally speaking, use float when you using the number to do calculations and Float when you need to store it in Object collections.

A: Float is an object; float is a primitive. Same relationship as Integer and int, Double and double, Long and long.
float can be converted to Float by autoboxing, e.g.
float f=1.0f;
Float floatObject = f;

or explicitly
Float floatObject = new Float(f);

Initially primitives were retained alongside the object versions for speed. Autoboxing/unboxing was added with java 5 to facilitate conversion.


text:
Q: if $K$ is the splitting field for $f(x)$ over $F$ and $deg f(x) = n$, then $[K:F] \leq n!$ I need some help understanding this proof/filling in the details.
I have the following:
We know in general that $[K:F] = [K:K_1][K_1:F]$ but $[K_1:F] = deg(h(x)) \leq n$ (if we consider $K_1$ the splitting field for some $h(x)$.
Apply induction.
$K$ is the splitting field for $f_1(x)$ over $K_1$, and $f_1(x)$ has degree
$n − 1$, so its degree is at most $(n − 1)!$.
I'm not sure how this induction works.  I assume we're using strong-induction.  I would appreciate it if somebody helped me fill in the details of the proof.


text:
Q: key="value"&key="value" String parsing in Java How can I parse a string like
success="true"&sign_type="RSA"&sign="xxx"
("" is included in the original string) into a Map or JavaBean?

A: Map<String, String> map = new HashMap<String, String>();
String[] arr = str.split("&");
for (String s : arr) {
    String[] a = s.split("=");
    map.put(a[0], a[1]);
}

A: Uri uri=Uri.parse(url_string);
uri.getQueryParameter("RSA");

A: string.split(String regex) will be your friend here.