Saturday, 15 January 2011

r - counting number of observations into a dataframe -



r - counting number of observations into a dataframe -

i want create new column in dataframe states number of observations particular group. have surgical procedure (hrg.code) , multiple consultants perform procedure (consultant.code) , length of remain patients in in days.

using

sourcedata2$meanvalue<-with(sourcedata2,ave(lengthofstaydays., hrg.code, consultant.code fun=mean))

i can new column (meanvalue) shows mean length of remain per consultant per procedure. need. however, i'd know how many occurances of each procedures each consultant performed new column in same info frame.

how generate number of observations. there doesn't appear fun = observations or fun = freq capability.

you may try:

tbl <- table(sourcedata2[,3:2]) #gives frequency of each `procedure` i.e. `hrg.code` done every `consultant.code` tbl # hrg.code #consultant.code b c # 1 1 0 # b 4 2 1 # c 0 0 1 # d 1 1 1 # e 2 0 0 as.data.frame.matrix(tbl) #converts `table` `data.frame`

if want total unique procedures done each consultant.code in long form.

with(sourcedata2, as.numeric(ave(hrg.code, consultant.code, fun=function(x) length(unique(x))))) # [1] 3 3 3 2 1 3 3 3 3 1 1 3 3 3 2 data sourcedata2 <- structure(list(lengthofstaydays = c(2l, 2l, 4l, 3l, 4l, 5l, 2l, 4l, 5l, 2l, 4l, 2l, 4l, 4l, 2l), hrg.code = c("c", "a", "a", "b", "a", "a", "b", "c", "a", "a", "c", "a", "b", "b", "a"), consultant.code = c("b", "b", "b", "a", "e", "b", "d", "d", "d", "e", "c", "b", "b", "b", "a")), .names = c("lengthofstaydays", "hrg.code", "consultant.code"), row.names = c(na, -15l), class = "data.frame")

r data.frame frequency

asp.net mvc 4 - SaaS Billing and Multi-tenant starter kit -



asp.net mvc 4 - SaaS Billing and Multi-tenant starter kit -

i'm finished solution built asp.net mvc. apart few bits , pieces, have security do. wondering if there sort of starter code somewhere can build application (or build current files into) following:

subscription page tenants (think called tenants, see note below), assign administrator account. a way invite others bring together , work on tenant's data. user groups , roles limit each of these other users can see/do. standard login/forgot password pages it doesn't need handle billing, if does, it's added bonus

my understanding of tenant here person signs , invite others access data. called vendor sometimes.

i'm sure there must out box, because above features of saas apps nowadays. i'm aware need add together clauses existing queries ensure tenants don't see each other's data.

any solutions anyhow know of? please allow me know. give thanks you

asp.net-mvc-4 saas starter-kits

c# - Display photos in dynamic folder asp.net -



c# - Display photos in dynamic folder asp.net -

i trying design photos manager website application need show of photos in folders base of operations on folder name , utilize 1 aspx page. found many tutorail can work display photos in folder dont know how display photos in folder on take galery, example: have folder photo on host server, in have 2 sub folders are: animal , flower. when click on animal folder, animal photos display on webpage , on when click on flower folder, flowers photos shown.

here code have: aspx page:

<asp:datalist id="datalist1" runat="server" repeatcolumns="5" backcolor="white" bordercolor="#999999" borderstyle="solid" borderwidth="1px" cellpadding="3" forecolor="black" width="100%"> <footerstyle backcolor="#cccccc" /> <selecteditemstyle backcolor="#000099" font-bold="true" forecolor="white" /> <headertemplate> <span class="style2">image gallary</span> </headertemplate> <headerstyle backcolor="black" font-bold="true" forecolor="white" /> <itemtemplate> <asp:imagebutton width="105px" id="image1" runat="server" borderstyle="solid" imageurl='<%# bind("name", "~/[foldername]/{0}") %>' height="94px" /> <br /> <asp:linkbutton id="hyperlink1" text='<%# bind("name") %>' commandargument='<%# bind("name") %>' runat="server" /> </itemtemplate> <footerstyle backcolor="white" forecolor="#333333" /> <itemstyle bordercolor="silver" borderstyle="dotted" borderwidth="1px" horizontalalign="center" verticalalign="bottom" backcolor="white" forecolor="#333333" /> </asp:datalist>

code behind

private void listimages() { directoryinfo dir = new directoryinfo(mappath("~/images")); // it's animal if click on animal , flower when click on flower. fileinfo[] file = dir.getfiles(); arraylist list = new arraylist(); foreach (fileinfo file2 in file) { if (file2.extension == ".jpg" || file2.extension == ".jpeg" || file2.extension == ".gif" || file2.extension == ".png") { list.add(file2); } } datalist1.datasource = list; datalist1.databind(); }

i tried add together list total path as: list.add(dir.tostring()+file2.tostring()) can not phone call aspx page <%# bind("name") %>, error wrong property name! :(

there 2 problem in code:

you need create property class name property. this:

public class imagetest { public string name {get;set;} }

then in bindlist method:

private void listimages() { directoryinfo dir = new directoryinfo(mappath("~/images/animal")); // it's animal if click on animal , flower when click on flower. fileinfo[] file = dir.getfiles(); // arraylist list = new arraylist(); list<imagetest> list = new list<imagetest>(); foreach (fileinfo file2 in file) { if (file2.extension == ".jpg" || file2.extension == ".jpeg" || file2.extension == ".gif" || file2.extension == ".png") { // list.add(file2); // list.add(dir.tostring() + file2.tostring()); list.add(new test() { name = "http://localhost:58822/images/animal/" + file2.tostring() // localhost path site url }); } } datalist1.datasource = list; datalist1.databind(); }

also need remove ~/[foldername]/{0}") %>' code , maintain simple

imageurl='<%# bind("name") %>'

c# asp.net

ios - Scrolling UICollectionView blocks main thread -



ios - Scrolling UICollectionView blocks main thread -

i have video decoder playing h264 using avsamplebufferdisplaylayer , works until scroll uicollectionviewcontroller on same view controller. appears block main thread causing app crash. have tried putting code in block on separate queue using dispatch_async still have same blocking problem along farther performance issues on decoder.

dispatch_async(samplequeue, ^{ [samplebufferqueue addobject:(__bridge id)(samplebuffer)]; if ([avlayer isreadyformoremediadata]) { cmsamplebufferref buffer = (__bridge cmsamplebufferref)([samplebufferqueue objectatindex:0]); [samplebufferqueue removeobjectatindex:0]; [avlayer enqueuesamplebuffer:buffer]; buffer = null; nslog(@"i frame"); [avlayer setneedsdisplay]; while ([samplebufferqueue count] > 0 && [avlayer isreadyformoremediadata]) { cmsamplebufferref buffer = (__bridge cmsamplebufferref)([samplebufferqueue objectatindex:0]); [samplebufferqueue removeobjectatindex:0]; [avlayer enqueuesamplebuffer:buffer]; buffer = null; nslog(@"i frame buffer"); [avlayer setneedsdisplay]; } } else { nslog(@"avlayer not accepting info (i)"); } });

is there way give task priority on user interface actions scrolling collection view etc? apologies lack of understanding reasonably new ios.

turns out uicollectionview blocking delegate calls nsurlconnection on main thread. solved problem:

nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self];

changed to

nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:no]; [connection scheduleinrunloop:[nsrunloop currentrunloop] formode:nsrunloopcommonmodes]; [connection start];

ios grand-central-dispatch

c# - Control.Invoke method not returning -



c# - Control.Invoke method not returning -

i'm trying parallelize code create run faster. far, it's been headaches , no results.

i want update several datagridviews @ same time :

parallel.invoke( () => updatedgv1(), () => updatedgv2(), () => updatedgv3() );

i have tried using easy (but not optimal) way recommended everywhere on web (like here http://msdn.microsoft.com/en-us/library/ms171728(v=vs.85).aspx ).

private void updatedgv1() { /* stuff */ assignvalue(this.dgv1, colpos, rowpos, value); /* in loop */ } delegate void assignevaluecallback(datagridview dgv, int columnpos, int rowpos, string valeur); public void assignvalue(datagridview dgv, form form, int columnpos, int rowpos, string value) { if (dgv.invokerequired) { assignevaluecallbackd = new assignevaluecallback(assignvalue); dgv.invoke(d, new object[] { dgv, columnpos, rowpos, value }); } else { dgv[columnpos, rowpos].value = value; } }

the main thread gets stuck @ "parallel.invoke(...)" call, waiting other threads finish.

the threads created "parallel.invoke(...)" stuck @ point:

mscorlib.dll!system.threading.waithandle.internalwaitone(system.runtime.interopservices.safehandle waitablesafehandle, long millisecondstimeout, bool hasthreadaffinity, bool exitcontext) mscorlib.dll!system.threading.waithandle.waitone(int millisecondstimeout, bool exitcontext) system.windows.forms.dll!system.windows.forms.control.waitforwaithandle(system.threading.waithandle waithandle) system.windows.forms.dll!system.windows.forms.control.marshaledinvoke(system.windows.forms.control caller, system.delegate method, object[] args, bool synchronous) system.windows.forms.dll!system.windows.forms.control.invoke(system.delegate method, object[] args) etc

why stuck?

i assume you're calling parallel.invoke ui thread. if so, that's problem.

parallel.invoke blocks until calls finish... means you're blocking ui thread. tasks you're starting can't complete, because control.invoke blocks until phone call on ui thread has finished - subtasks waiting ui thread become available in order update ui, ui thread waiting subtasks finish.

you could prepare using begininvoke instead of invoke (and may want anyway) it's fundamentally bad thought utilize parallel.invoke in ui thread, exactly because blocks.

c# .net-4.0

excel - adding a dynamic cell reference in vba -



excel - adding a dynamic cell reference in vba -

i using next code insert formula cell using vba. code inserts hyperlink static text leading file path , @ end of file path want able add together dynamic cell reference, instance , number of row.

in cell in column have names of folders. using destrow define current row number. question how can right formula when link clicked opens link right folder name of row clicked? thanks

ws2.range("s" & destrow).formula = "=hyperlink(""\\uksh000-file06\purchasing\new_supplier_set_ups_&_audits\attachments\"" & k" & destrow & ",""attached"")"

try,

ws2.range("s" & destrow).formula = "=hyperlink(""\\uksh000-file06\purchasing\new_supplier_set_ups_&_audits\attachments\" & ws2.range("k" & destrow).value & """,""attached"")"

fwiw, hate working quoted strings well.

addendum: should adding static filename after dynamic folder:

ws2.range("s" & destrow).formula = "=hyperlink(""\\uksh000-file06\purchasing\new_supplier_set_ups_&_audits\attachments\" & ws2.range("k" & destrow).value & "\audit.xls"",""attached"")"

excel vba hyperlink

ios - Asset Catalog UIImage ImageNamed: was nil -



ios - Asset Catalog UIImage ImageNamed: was nil -

i have 2 assets catalogs in app. 1 in source directory of app , other 1 linked project , target membership set.

when load image linked assetscatalog with

[uiimage imagenamed:@"icon_close"];

the image nil

when load image form asset catalog in sourc directory loaded

can help me have no thought why image not loaded.

in old projects work fine when create project xcode 6 dose not work.

ios xcode uiimage asset-catalog