Posts

Showing posts from March, 2011

ruby on rails - Custom devise session controller error with json -

i'm using devise simple-token-authentication user authenticate in restfull webservice. when make requisition invalid token, error below. can do? started "/users/sign_in.json" ::1 @ 2015-04-22 16:09:27 -0300 processing sessionscontroller#new json completed 406 not acceptable in 4ms actioncontroller::unknownformat (actioncontroller::unknownformat): responders (2.1.0) lib/action_controller/respond_with.rb:205:in `respond_with' devise (3.4.1) app/controllers/devise/sessions_controller.rb:11:in `new' actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action' actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action' i solved problem with class sessionscontroller < devise::sessionscontroller respond_to :html, :

html - Adding and subtracting height in Jquery BUGGING -

im adding/subtracting height on div element, ul inside it. add/subtract events fire upon click on other unrelated divs in document. now.. problem occurs when user spamfires event. this, for unknown reason , results in, div on add/subtract height, either increase or lower it's base height. note - i'm adding , subtracting exact same amount, , therefore, base height of div in question, should not either increase or lower. i apologize following fiddle's extensive code, i've had cp sourcecode, seeing couldn't achieve same bug, recreating example. http://jsfiddle.net/st5dzcnc/ in js section, refer 3 $(function)'s. in result section, i've marked 3 elements trigger event, in orange , stated "spamclick here". doing forementioned result in blue div below, either increasing or lowering it's base height - need avoid happening. <div>refer jsf</div> i've tried doing think of fix this, nothing has worked, i'm @ complet

asp.net - RegisterProperty cache display name -

i'm using registerproperty csla. have displayattribute , displaynameattribute on properties attached resource. notice .name property of each of registerproperty cached. if switch language, .name not refreshed. causes trouble since i'm using stringlengthattribute , others handle business rules. is there way refresh .name or make sure value isn't cached? for decided create own attribute takes display name parameter. there way disable caching. public class stringlengthexattribute inherits stringlengthattribute private _displayresourcename string = "" public sub new(byval maximumlength integer) mybase.new(maximumlength) me.errormessageresourcename = "ruleexceedmaxcharacter" me.errormessageresourcetype = gettype(my.resources) end sub public sub new(byval displayresourcename string, byval maximumlength integer) mybase.new(maximumlength) _displayresourcename = displayresourcename

android - Jsoup parsing HTML tables (substitute plan) -

first of all, im german, don't hate me bad english ;) im working @ moment on app school. problem is, informations need, in html file on page . there way save "td" tags in array or strings? html code: <!doctype html public "-//ietf//dtd html//en"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><meta http-equiv="expires" content="0"><meta name="keywords" content="stundenplan, timetable"> <meta name="generator" content="untis 2015"> <title>untis 2015 stundenplan 2014/15 dietrich-bonhoeffer-gymnasium 1</title> <style type="text/css"> {color:#000000;} </style> <link rel="stylesheet" href="../../untisinfo.css" type="text/css"> </head> <body bgcolor="#ffffff"> <center><font size="3" face=&

json - Jackson mapper with generic class in scala -

i trying serialise generalresponse : case class generalresponse[t](succeeded: boolean, payload: option[t]) and payload groupsforuserresult : case class groupsforuserresult(groups: seq[uuid]). i using mapper.readvalue(response.body, classof[generalresponse[groupsforuserresult]]) unfortunately payload serialised map , not desired case class ( groupforuserresult ). because of java erasure - jackson can't know @ runtime generic type t line - mapper.readvalue(response.body, classof[generalresponse[groupsforuserresult]]) a solution problem mapper.readvalue(json, new typereference[generalresponse[groupsforuserresult]] {}) this way provide instance of typereference needed type information.

makefile - Make doesn't finish when run with entr -

i'm trying use entr recompile change c file following command: $ echo ex8.c | entr make ex8 && ./ex8 when run cc output nothing happends $ echo ex8.c | entr make ex8 && ./ex8 cc -wall -g ex8.c -o ex8 if write manually works great $ make ex8 && ./ex8 how should write entr work? the man page wasn't quite detailed enough, installed , tried it. note command 3 distinct shell commands: echo ex8.c , entr make ex8 , , ./ex8 . these connected pipe (the first two) , && operator (the final two). 2 commands in pipeline both started in parallel. final command not invoked until pipeline completes, if exit code success run. this means final command ./ex8 not started until after entr make ex8 command finishes. but, entr not exit after runs make 1 time: entire point continue watch source file , run make every time changes. that's why final command never invoked: entr never exits. there multiple ways fix simplest

r - How to predict new raster using model generated by cforest -

i use randomforest model predict class memberships. 'x' consists of 10 classes use train 'training_predictors' values extracted large rasterstack/brick. specific line of codes is: r_tree<-randomforest(x ~. , data=training_predictors, ...) then run 'predict' using model 'r_tree' apply rasterstack 'predictor_data', follow: predictions<-predict(predictor_data, r_tree, filename=outraster, fun=predict na.rm=true, format="pcdisk", overwrite=true, progress="text", type="response"). the output raster use thematic map. i use conditional inference trees mode 'cforest' instead of randomforest achieve same goals. i understand 'predict' can used cforest, yet, have not been able generate raster files, such randomforest illustrated above. it should run fine, may need add argument oob=true, , identify factors if there any. example data p <- matrix(c(48, 48, 48, 53, 50, 46

spring data rest query by nested object -

i have spring data rest application using jpa underlying implementation. have data model similar following: @entity public class person { @id private long id; private string name; @manytoone private address address; } @entity public class address { @id private integer id; private string street; private string city; private string state; private string zip; @onetomany(mappedby = 'address') private list<person> people; } i've left out getter/setters, there. have 2 crudrepository interfaces defines access 2 entities. on personrepository , i've defined method findbynameandaddress . intent search people given name , have linked address. problem think i'm supposed pass in id of address in findbynameandaddress query. since i'm doing of via rest client, never have id. when retrieve address entities addressrepository , sdr removes id field json respresentation. according i've read, idea use self link when referring ent

android - AppCompat v22.1.0 not theming all xml widgets correctly for fragments -

Image
when using xml based layouts using appcompat 22.1.0 not supported widgets tinted or material themed fragments using android 4.4. i see behavior following widgets (others not tested): radiobutton (no tint color) checkbox (no tint color) spinner (device default theme applied) edittext (device default theme applied) ratingbar (device default theme applied) button (device default theme applied) it used work in appcompat v22.0.0. screenshot (left 4.4, right 5.0): mainactivity.java: public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (savedinstancestate == null) { getsupportfragmentmanager() .begintransaction() .add(r.id.container, new placeholderfragment()) .commit(); } } public static class placeholderfr

Removing multiple elements from a vector c++ -

here code checks if 2 units killed after attack each other, pass in position in vector when remove 1 vector changed in size , therefore 2nd unit out of range. how can remove both simultaneously? if ((myhealth <= 0) && (enemyhealth <= 0)) { playerunits.erase(playerunits.begin() + myunit, playerunits.begin() + enemyunit); } else if (myhealth <= 0) { playerunits.erase(playerunits.begin() + myunit); } else if (enemyhealth <= 0) { playerunits.erase(playerunits.begin() + enemyunit); } first point: in first block, call erase(x, y) different expect - erases whole range of elements starting @ index x until before index y. example, if have vector [a,b,c,d,e,f,g], erase(2,5) erase indexes 2,3,4, end [a,b,f,g]. i'm guessing want erase 2 elements, not entire range. second point: dieter lücking pointed out, erase higher index element first, this: if (myunit > enemyunit) { playerunits.erase(playerunits.begin() + myunit); playerunits.

What is the SQL Loader equivalent in SQL Server for extracting a database from SQL Server to the same server? -

i trying replicate or copy database in sql server 2014 in order create sandbox. know sql loader oracle. there equivalent tool in sql server? you might in following ways: 1.stop sql server, copy *.mdf file locating right clicking on existing database -> properties server destination sever , attach destination server using ssms. 2.create ssis package , execute using dtexec.exe .you can create .bat file ,configure , call dtexec.exe .bat file.this alternatve oracle sql loader etl tasks.

asp.net mvc - Can a forms authentication cookie .ASPXAUTH be used to assign a user to a MVC 5 OWIN application's context? -

can .aspxauth forms authentication cookie used in mvc 5 owin-based application create user in httpcontext.user property? both applications share same machinekey , domain/server same. .aspxauth cookie available in mvc 5 application's owincontext.request.cookies collection. in mvc 5 owin-based project: you should think several things. that's how works me: do things described in this article (see github project ) dont forget set "compatibilitymode" machinekey tag in web.config in both projects example <machinekey compatibilitymode="framework20sp1" validationkey="..."/> validationkey , decryptionkey , validation , description should same in both sites. then had rewrite methods protect public string protect(authenticationticket data) { var ticket = new formsauthenticationticket( 2, data.identity.name, datetime.now, datetime.now.addminutes(2880), true, ""); var ret = formsauthenti

javascript - D3.js Decision Tree - text wraping, bounding box, # of load circles -

i'm trying create decision tree in d3. problems: - text goes off right side, can/how set bounding box stop that? the text in circle isn't wrapping. willing make circles bigger fit text, wrapping still problem. how first 3 circles show on load? var treedata = [ { "name": "tk question here that's long", "content":"question here long", "parent": "null", "children": [ { "name": "level 2: a", "parent": "top level", "children": [ { "name": "son of a", "parent": "level 2: a" }, { "name": "daughter of a", "parent": "level 2: a" } ] }, { "name": "level 2: b",

java - SwipeRefreshLayout - the RecyclerView is not pulled down -

i have recyclerview gridlayoutmanager , when using swiperefreshlayout recyclerview not pulled down. how create effect of having gap between toolbar , recyclerview while refreshing? xml: <progressbar android:id="@+id/progressbar" style="?android:attr/progressbarstylelarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <android.support.v4.widget.swiperefreshlayout android:id="@+id/swipe_container" android:layout_width="match_parent" android:layout_height="match_parent"> <recyclerview android:id="@+id/gridview" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.widget.swiperefreshlayout> </framelayout&g

security - php - right GET handling -

i have file users.php , want display user's information when set example users.php?id=5 my "users.php" file is: <?php $page_title = "administrace - uživatelé"; require_once($_server['document_root']."/core/main.php"); if(!admin::is_admin() or !user::is_logged()) // check if user logged , admin { redirect($url."index.php"); //get out of here } $user = new user(); if(isset($_get["id"])) { $id = test_input($_get["id"]); // = htmlspecialchars() & trim() & stripslashes() $is_valid = ctype_digit($id); if($is_valid && $user->check_user_available($id)) // check if $id number , if user $id in database { // show user's information } else { // out of here redirect($url."admin/"); } } else { ?> <i>...toto je random text...</i> <section> <div class="content">

javascript - decode json with number object in php -

i working http api sending sms. trying decode json file receive after made post url. want know how can decode thing.. if static can decode fact have number key may increase extension. in case , how decode post , need save in mysql. please me out of problem. {"msg_id":"4396-7666-1337896-1dc5c765ad7-5537bb07-123638242","senderid":"execut","linecount":"1","billcredit":"0.00","message":"hello+test+message","sendondate":"2015-04-22 20:45:00","seq_id":{"**1**":{"valid":"true","billcredit":"1.00","id_provider":"24","providerkey":"hutch","regionkey":"wb","originalnumber":"1234567890","validnumber":"1234567890","mnpid":"106","dlr_seq":1},"**2**":{"valid":"true

Spring Boot change value properties file -

hi i'm using spring boot. dynamically replace contents of variable in properties file. this file: message.properties message=welcome ${bean.name} website i know if there way change value of variable. thanks if comes messages.properties file, don't have change dynamically content. instead can use message variables. take @ example: messages.properties: message=welcome {0} website if process message using messagesource bean, can message with: messagesource.getmessage("message", new object[] { "test" }, localecontextholder.getlocale()) the returned string in case is: welcome test website of course need inject messagesource class (controller,service) before can use exemplary code: @autowired messagesource messagesource

asp.net - Is possible to execute Powershell Azure CMDlets from web application? -

now can execute powershell azure cmdlets , scripts asp mvc web app when running locally, when deployment azure web sites powershell azure cmdlets doesn't work. error message: the term 'get-azuresubscription' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again. i guess not work because "azure cmdlets" not installed on web server what can do? advice? hi again, im testing application hosted in iis8 in azure virtual machine, again when app deployed server cannot use azure cmdlets, azure cmdlets installed on virtual machine. when debug app in vm visual studio can use cmdlets, when app deployed cmdlets no recognized. there else need setup in order use azure cmdlets??? this example of 1 function, function populate dropdownlist result, in localhost works fine, in iis. public ienumerable<selectlistitem> getimagefamily() {

java - prevent gridView from expanding to fit landscape width -

i have gridview 4 columns of imgs. when phone turned landscape layout, grids of gridview expand fill width, creating white spaces in between img although img stay @ desired width. there way keep grid view filling width of screen when in landscape layout ? i have 2 methods that: 1) create layout each orientation: res/layout/.... res/layout-land/.... 2) 1 layout both vertical , horizontal orientation: set gridview with: android:numcolumns="4" your custom view item, set android:layout_width="match_parent" with second method, may encount problem high of item. create custom view , override onmeasure . for example: need linearlayout item , keep ratio height/width = 4.5/4 , following custom: public class mylinearlayout extends linearlayout { //..... constructor methods @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { int scaleheight =(int)( widthmeasurespec/4*4.5); super.onmeasure(w

java - Custom Animation end trigger -

i'm writing "space invaders" style app , needed move stop repeat animation classic game. got processes go 1 way, using code below, when want go back, there not seem easy way this. think easiest way have happen on end animation event, cannot event trigger, when calling super.end(); . i've looked around way trigger event manually no avail. way doing may little sketchy works enough right try , make work way. public void start() { if(begin < end) //recursive end condition { int distance = interval + begin; //change distance traveled //create new animation part of whole animation objectanimator anim = objectanimator.offloat(toanimate, property, begin,distance); timeinterpolator inter = new timeinterpolator() //makes animation move 1 frame { public float getinterpolation(float prog) { return math.round(prog * 10) / 10; } }; anim.setinterpolator(inter

Load an HTML page from local with getURL in R -

i'm trying load html page local directory geturl: library(rcurl) my_page<-geturl("my_page.html") but get error in function (type, msg, aserror = true) : not resolve host: my_page.html how can describe right path ? try my_page<-geturl(paste0("file:///", getwd(), "/my_page.html"))

css - How do I include conditional formatting within a style attribute? -

right i'm coding email , need apply specific padding outlook 2007 , higher. @ moment have conditional formatting applied @ end of style attribute override "default" padding, this: <table cellpadding="0" cellspacing="0" border="0" width="211" align="left" class="ending_soon_table" style="float: left; padding: 0 10px; <!--[if gte mso 12]>padding: 0 7px;<![endif]-->"> any tips on how should formatting differently? can more specific? fiddle this? good practice use whole statement padding: <table style="padding: top right bottom left;"></table> not top-bottom && right-left declaration. also try !important make sure override existing css (note: use !important testing.) than statement used greater mso(ffice) 12. want or need above 2007 version? in case need above 2007, change to: <!--[if gte mso 7]>padding: 0 7px;<![end

ios - scrollView: how to create a pure auto layout scrollview with paging? -

can tell me did wrong here... - pin uiscrollview container view - pin subviews onto uiscrollview after reading apple technote it, tried both hybrid method , pure auto layout method. hybrid method using nib works awful paging, looks big picture in scrollview, rather paged. i created pure auto layout version in code, uiscrollview subview of uiview. time view stuck, , uiimage gigantic, full size: //scroll view if (self.scrollview == nil) { self.scrollview = [[uiscrollview alloc] initwithframe:self.frame]; self.scrollview.translatesautoresizingmaskintoconstraints = no; [self.scrollview setclipstobounds:no]; [self.scrollview setpagingenabled:yes]; [self addsubview: self.scrollview]; [self addconstraints: [nslayoutconstraint constraintswithvisualformat:@"h:|[scrollview(300)]|" options:0 metrics:nil vie

amazon ec2 - How do I upload my uber-jar to a spark cluster created using the spark-ec2 scripts? -

i create ec2 spark cluster in 1 line of code using spark_home/ec2/spark-ec2 i'm using --copy-aws-credentials (spark 1.2.0) sc.textfile("s3...") works well my issue silly, how copy jar master? aws cli doesn't seem setup correctly can't use s3 directly. i can make jar public , wget bad practice. i tried connect master outside, it's blocked what best practice submitting uber jar spark standalone amazon ec2 cluster launched via ec2/spark-ec2 ?

java - HTTP status 404 error from Tomcat -

i'm new servlet i'm testing first servlet program giving http status 404 error. things have done are: 1> installed java-> c:\program files\java\jdk1.6.0 2> installed tomcat-> c:\apache-tomcat-7.0 3> when type -> localhost:8080 in browser works fine. 4> directory folder created-> c:\apache-tomcat-7.0.23\webapps\examples. it contains web.xml file , web-inf folder. inside web-inf, there folder named classes, contains validate.class the souce code java file 'validate.java' given below- import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.lang.*; public class validate extends httpservlet{ public void service(httpservletrequest req,httpservletresponse res) throws servletexception,ioexception{ string name=req.getparameter("tb"); string pass=req.getparameter("pass"); string name1=getinitparameter("usrnme1"); string pass1=getinitparameter("pswrd1");

javascript - How to encode a text diagram into json? -

i'm trying encode oauth2 diagram string in json object. when "decode" using builtin js parsejson function output looks broken. idea why or how should encode ? plunkr function show(){ var diagram = ' +----------+\ | resource |\ | owner |\ | |\ +----------+\ ^\ |\ (b)\ +----|-----+ client identifier +---------------+\ | -+----(a)-- & redirection uri --->| |\ | user- | | authorization |\ | agent -|----(b)-- user authenticates -->| server |\ | | | |\ | |<---(c)--- redirection uri ----<| |\ | | access token +---------------+\ | | in fragment\ | | +---------------+\ | |----(d)--- redirection uri