Friday, 15 January 2010

r - Syntax (and/or functions) for applying an op over elements of one vector, using as arg elements of a 2nd vector -



r - Syntax (and/or functions) for applying an op over elements of one vector, using as arg elements of a 2nd vector -

i trying find right look creating vector result applying operation on vector, using, in vectorised way, elements of 2nd vector. utilize case have vector of raw values, , vector of breakpoints. want look give me result of applying sum of logical operation on breakpoints respect values in values vector. in other words:

given:

rawfoo <- c(30, 4, 22, 77, 1,169, 10) breaksfoo <- c(10,50, 80) resultfoo <- data.frame(breaks=breaksfoo, matching=numeric(length(breaksfoo)))

i want write single expression delivers column values resultfoo$matching, is: each value in breaksfoo, sum(rawfoo > breaksfoo[i]),

resultfoo breaks nmatching 1 10 3 2 50 2 3 80 1

i have been trying various forms of apply , having problems how express function. perhaps barking wrong tree? can supply multiple demonstration of failure if required. (but guess question simple doesn't need error messages disambiguate ;-)

you can in 3 steps:

write function that, given break, returns list of 2 element: break , result of sum(break > rawfoo).

than can utilize sapply apply function breaksfoo.

finally, need transform result of sapply, matrix, dataframe need.

the next code of these 3 steps in 1 statement:

as.data.frame(t(sapply(breaksfoo, function(x) list(breaks = x, nmatching = sum(x > rawfoo)))))

returns

breaks nmatching 1 10 2 2 50 5 3 80 6

r syntax apply

Kerberos authentication using Java is failing -



Kerberos authentication using Java is failing -

my client has run in problem java application (i have not played in java land in long time). application uses kerberos authentication , works great java 1.6.30. upgrade java 1.7.11 begin getting next error:

javax.secrutiy.auth.login.loginexception: unable obtain principal name authentication.

the jvm running on windows 7 in windows domains authenticating against ad. there breaking alter made between releases? there code alter need fixed? or did on java team goof up? tia

hi running potential problem.

http://www.javaactivedirectory.com/?page_id=93

java 6 doesn't respect registry value while java 7 does.

java kerberos

html - Execute some Javascript onChange using options? -



html - Execute some Javascript onChange using options? -

i've been lurking bit , couldn't find answer. have bunch of buttons want turn drop downwards menu , have code executed onchange. but, i'm new javascript , having hard time figuring out how work. got work, couldn't work more 1 option. here's have:

<button class="lightbutton" onclick="lightswitch(1,true);lightswitch(2,true);lightswitch(3,true);"> lights on</button> <button class="lightbutton" onclick="lightswitch(1,false);lightswitch(2,false);lightswitch(3,false);"> lights off</button>

i got lights turn on doing this:

<form name="functions"> <select name="jumpmenu" onchange="lightswitch(1,true);lightswitch(2,true);lightswitch(3,true);"> <option>lightfunctions</option> <option value="*";>light 1 on</option> <option value="*";>light 1 off</option> </select> </form>

now, see why works -- it's telling whenever changes turn on lights. how alter "onchange" create gets whichever alternative have chosen?

i think i'm missing js unsure.

i appreciate help.

to have select element command first lightswitch can this:

<select name="jumpmenu" onchange="lightswitch(1,this.value==='on');"> <option value="on";>light 1 on</option> <option value="off";>light 1 off</option> </select>

that is, instead of hardcoding true sec parameter lightswitch() test current value of select element. (note i've changed value attributes more meaningful. look this.value==='on' evaluate either true or false.)

within select's onchange attribute this refer select element itself.

edit: have same select command multiple parameters can add together data- attributes alternative elements store many parameters per alternative needed (in case think need 1 extra). , i'd move logic out of inline attribute:

<select name="jumpmenu" onchange="jumpchange(this);"> <option value="">lightfunctions</option> <option data-switchno="1" value="on";>light 1 on</option> <option data-switchno="1" value="off";>light 1 off</option> <option data-switchno="2" value="on";>light 2 on</option> <option data-switchno="2" value="off";>light 2 off</option> <option data-switchno="3" value="on";>light 3 on</option> <option data-switchno="3" value="off";>light 3 off</option> </select> function jumpchange(sel) { if (sel.value === "") return; // nil if user selected first alternative var whichlight = +sel.options[sel.selectedindex].getattribute("data-switchno"); lightswitch(whichlight, sel.value==='on'); sel.value = ""; // reset select display "light functions" alternative }

demo: http://jsfiddle.net/n7b8j/2/

within jumpchange(sel) function added parameter sel select element (set this onchange attribute). "magic" happens on line:

var whichlight = +sel.options[sel.selectedindex].getattribute("data-switchno");

to explain line: sel.options[sel.selectedindex] gets reference selected option, , .getattribute("data-switchno") gets option's data- attribute. + converts attribute string number.

javascript html jsp option onchange

asp.net mvc - Microsoft MVC Razor - EditorFor and Digitalbush mask not working -



asp.net mvc - Microsoft MVC Razor - EditorFor and Digitalbush mask not working -

i cannot mask command exclusively work. simple mvc editorfor line shows fails mask input. i'm sending timespan value it.

@html.editorfor(model => model.vxchargebo.visittime)

should mask _ _ : _ _ instead shows time passed 00:00:00

i've tried adjusting mask, problem seems in mvc or css wanted rule out mvc.

use:

@html.textboxfor(model => model.vxchargebo.visittime)

asp.net-mvc input mask editorfor

WPF: How to save a GIF file in a string or file from an URL? -



WPF: How to save a GIF file in a string or file from an URL? -

i seek retrieve content of .gif located on url string -and save disk-, ran wpf appliactions using webbrowser. after trying dozens of solutions not farther yesterday. thought code below job, saved string cgif contains...the url itself. http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.gifbitmapdecoder.aspx thought needed gifbitmapencoder instead, sample suggests creates empty gif instead of downloaded one.

(ps: want retrieve gif bytes straight wpf webbrowser haven't found working there either)

private void gifsave() { var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); var img = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); string cgif = img.tostring(); }

modified sample on gifbitmapdecoder msdn page:

// open stream , decode gif image var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); gifbitmapdecoder decoder = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); bitmapsource bitmapsource = decoder.frames[0];

then utilize copypixels() method of bitmapsource re-create pixel info array. convert array string?

i haven't done this, took @ msdn hints.

wpf string save uri gif

css - Two background images. One in HTML one in BODY. In Firefox body image isnt rendered -



css - Two background images. One in HTML one in BODY. In Firefox body image isnt rendered -

something weird happening.

i've basic html code. html, head, body. (as i've received negative votes, here's total code)

<html> <head> </head> <body> </body> </html>

this css:

html { background-image: url(background.png); background-repeat: repeat; margin-top:-8px; } body { background-image: url(telefonillo.png); background-repeat:no-repeat; }

this chrome , firefox shows:

how can prepare this?

i tried "inspect" firefox, , tried remove "background.png" html, "telefonillo.png" shows up.

tried "z-index:1" on body, isn't working, isn't content @ all.

edit: tried removing divs, , other css, incase there kind of problems between rules, it's still happening.

why don't utilize before

body:before { content:""; background:url(background.png) no-repeat top left; width:100%; height:100%; } body { background:url(telefonillo.png) no-repeat top left; width:100%; height:100%; }

html css

c# - DateTime.ParseExact raises FormatException -



c# - DateTime.ParseExact raises FormatException -

the code:

datetime.parseexact("2/2/2002", "dd/mm/yyyy", system.globalization.cultureinfo.invariantculture)

is raising system.formatexception.

i'll appreciate if tell me doing wrong.

it should d/m/yyyy

datetime.parseexact("2/2/2002", "d/m/yyyy", system.globalization.cultureinfo.invariantculture)

the reason of exception converts 2 places dd string found 2/.

c# .net datetime