Posts

r - Shiny app for prediction with rpart displaying error -

i tried build shiny app. objective let user input csv file in input box. user can input dependent variable name in text box. main panel display summary details of model fit , plot. i have coded following ui.r : library(shiny) shinyui(fluidpage( titlepanel(h1("analysis",align = "center")), sidebarlayout( sidebarpanel( fileinput('file1', 'select csv file', accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')), textinput("text", label = strong("dependent variable"), value = "enter dependent variable...") ), mainpanel(br(), textoutput('text1'), plotoutput('plot') ) ) )) the following server.r : library(shiny) library(rpart) library(rpart.plot) shinyserver(function(input, output) { ...

ruby on rails - How can I add a role to a user? (devise + cancancan) -

as have written in title don't know how can add roles user. made tutorial . my session_controller.rb class sessionscontroller < applicationcontroller skip_authorization_check def update id = params[:id].to_i session[:id] = user::roles.has_key?(id) ? id : 0 flash[:success] = "your new role #{user::roles[id]} set!" end end my ability.rb class ability include cancan::ability def initialize(user) user ||= user.new if user.role?(:admin) can :manage, :all else can :read, :all end end end and in user.rb model roles = {0 => :guest, 1 => :admin} attr_reader :role def initialize(role_id = 0) @role = roles.has_key?(role_id) ? roles[role_id] : roles[0] end def role?(role_name) role == role_name end now able on demo page

c# - How to change base url of Swagger in ASP.NET core -

by default when enable swagger in asp.net core project it's available on url: http://localhost:<random_port>/swagger/ui i use different base url instead of /swagger/ui . how/where can configure that? i found older versions can configure rooturl there aren't similiar method in asp.net core: .enableswagger(c => { c.rooturl(req => mycustombasepath); }); the useswaggerui() extension method enable middleware in configure method of startup class takes 2 variables. baseroute on swagger/ui default, , swaggerurl on swagger/v1/swagger.json default. provide different baseroute. //swagger available under '/api' url app.useswaggerui("api"); if people learn more configuring swagger asp.net core, i've written blogpost started: https://dannyvanderkraan.wordpress.com/2016/09/09/asp-net-core-1-0-web-api-automatic-documentation-with-swagger-and-swashbuckle/

c++ - Access violation error when creating pointer to pointer List -

i,m trying create pointer pointer list list<objectclass*> *lst_testlist; and trying use way void functioningclass::functioningmethod() { objectclass *object = new objectclass(); object->i_testing = 234; lst_testlist->push_back(object); object = lst_testlist->front(); cout<<object->i_testing; std::getchar(); } i can build program. when run it,it gives me error. unhandled exception @ 0x012885da in consoleapplication7.exe: 0xc0000005: access violation reading location 0x00000004. notice when create list list<objectclass*> lst_testlist; and use this, lst_testlist.push_back(object); it didn,t give me error. such list<objectclass*> lst_testlist; variable default-initialized . for pointer list<objectclass*>* lst_testlist; default initialization not performed. proper initialization is: list<objectclass*>* lst_testlist = new list<objectclass*>(); or list<objectclass*>* ...

java - reformat json from database query -

this current [{ "year": "2015", "org_name": "mooe", "suborg_name": "forms expenses", "amt": "2", "org_id": "4", "suborg_id": "24" }, { "year": "2016", "org_name": "mooe", "suborg_name": "forms expenses", "amt": "1", "org_id": "4", "suborg_id": "24" }] i want format [{ "org_name": "mooe", "suborg_name": "forms expenses", "suborg_id": "24", "org_id": "4", "year": [{ "year": "2015", "amt": "2" }, { "year": "2016", "amt": "1" }] }] below how current values: list<st...

Spark dataframe explode function -

can please explain why case row , seq[row] used after explode of dataframe field has collection of elements. , can please explain me reason why asinstanceof required values exploded field? here syntax: val explodeddepartmentwithemployeesdf = departmentwithemployeesdf.explode(departmentwithemployeesdf("employees")) { case row(employee: seq[row]) => employee.map(employee => employee(employee(0).asinstanceof[string], employee(1).asinstanceof[string], employee(2).asinstanceof[string]) ) } first note, can not explain why explode() turns row(employee: seq[row]) don't know schema of dataframe. have assume has structure of data. not knowing original data, have created small data set work from scala> val df = sc.parallelize( array( (1, "dsfds dsf dasf dsf dsf d"), (2, "2344 2353 24 23432 234"))).todf("id", ...

json - adds backward slash while json_encode -

------------------------ start ------------------------ {"oxitrxid":"00000175052408201611","msg":"0|{\"ticket_ref_no\":\"ets0s68691463\",\"ticket_id\":\"16907\",\"userid\":\"7002\",\"track_id\":\"57bd3908a8a9416907\"}","mtrxid":"bos0851161472018696","paidamt":"950.00","trxstatus":"0","trxmsg":"success","othervals":"{\"ticket_ref_no\":\"ets0s68691463\",\"ticket_id\":\"16907\",\"userid\":\"7002\",\"track_id\":\"57bd3908a8a9416907\"}","omtid":"hr010100203"} ------------------------ end ------------------------ i want remove forward slash above encoded array, tried use json_unescaped_slashes tried use str_replace nothing replaces it. $a = array ...