Posts

Showing posts from August, 2015

ghostdoc - How to document a file that is not in a solution? -

i have need document methods/functions in *.cpp code files not part of .net solution. until workaround has been create solution, time consuming step different files come across. does know how can accomplished? scott, unfortunately, workaround have use long ghostdoc relies on of information visual studio codedom... codedom not provide any info when open single file. do mind me asking if there particular reason opening single file in vs? other these might random files not part of solution? thanks!

reactjs - React Router: Call component function on RouteHandler ref -

i'm trying call component function on child component routehandler. var bar = react.createclass({ baz: function() { console.log('something'); }, render: function() { return <div />; }, }); var foo = react.createclass({ baz: function() { this.refs['ref'].baz(); }, render: function() { return <routehandler ref="ref" />; }, ); where routehandler bar this.refs['ref'].baz undefined . see https://facebook.github.io/react/tips/expose-component-functions.html more information on component functions. i don't believe react-router supports exposing component functions on routehandlers , current hacky workaround do: this.refs['ref'].refs['__routehandler__'].baz(); see https://github.com/rackt/react-router/issues/1597

java - Hibernate - fetch data from multple tables using many to one annotation -

i have 3 tables like: car carid|carname|carprice| 100|bmw|10l| 200|honda|5l| .. .. cartype cartypeid|type| 1|suv| 2|xuv| 3|sedan| carconfig carid|cartypeid| 100|3| 200|3| and have entities 3 tables. below have pasted code joining table carconfig : @entity @table(name = "carconfig", uniqueconstraints = { @uniqueconstraint(columnnames = { "carid" } ) }) public class carconfig { @id long carid; @onetoone @joincolumn(name = "carid", insertable = false, updatable = false) car car; @manytoone(optional = false) @joincolumn(name = "cartypeid") cartype cartype; public carconfig() { super(); } public carconfig(long carid, cartype cartype) { super(); this.cartype = cartype; this.carid = carid; } public car getcar() { return car; } public void setcar(car car) { this.car = car; } public cartype getcartype()...

wso2 - ArrayIndexOutOfBoundsException when adding a new API in wso2am -

i downloaded wso2am-1.9.0.zip macbook , expanded it. did not change of config or else. started bin/wso2server.sh, documented. seemed start successfully. able login api publisher admin/admin, documented. when tried add simple new api (just 1 endpoint) got following stacktrace: [2015-07-22 12:47:06,801] error - add:jag org.mozilla.javascript.wrappedexception: wrapped java.lang.arrayindexoutofboundsexception: 0 (/publisher/modules/api/add.jag#99) @ org.mozilla.javascript.context.throwasscriptruntimeex(context.java:1754) @ org.mozilla.javascript.memberbox.invoke(memberbox.java:148) @ org.mozilla.javascript.functionobject.call(functionobject.java:386) @ org.mozilla.javascript.optimizer.optruntime.call1(optruntime.java:32) @ org.jaggeryjs.rhino.publisher.modules.api.c3._c_anonymous_5(/publisher/modules/api/add.jag:99) @ org.jaggeryjs.rhino.publisher.modules.api.c3.call(/publisher/modules/api/add.jag) @ org.mozilla.javascript.scriptruntime.applyorcall(scriptr...

themes - Styling the application with android/style -

i trying style app using android:theme="@android:style/theme.holo" keep getting error @ runtime: java.lang.runtimeexception: unable start activity componentinfo{com.example.ghanghan.myapplication/com.example.ghanghan.myapplicat‌​ion.myactivity}: java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity. i later discovered anytime use @android:style/ same error. is there sone library need import? note: minimum sdk set 19.

c# - Refactor dublicate methods with generics -

i have methods. how can refactor code have generic method? first method: void changeprojectname(datamodel datamodel) { foreach (project project in datamodel.projects) { string projectname = project.name; projectname = changename(projectname); project.name = projectname; } datamodel.submitchanges(); } second method: void changeemployeename(datamodel datamodel) { foreach (employee employee in datamodel.employees) { string employeename = employee.name; employeename = changename(employeename); employee.name = employeename; } datamodel.submitchanges(); } we must able t type collection appropriate property in model, must pass selection strategy it: void changename<t>(datamodel datamodel, func<datamodel, ienumerable<t>> selector) t : ihavename { foreach (t x in ...

scala - Is 'def eat():Unit = sleep(); def sleep(): Unit = eat()' a tail recursive function? -

two functions: def eat(): unit = sleep() def sleep(): unit = eat() both of them recursive functions, because called in body (indirectly), right? but tail recursive functions? both of them recursive functions, because called in body (indirectly), right? yes, called mutual recursion . but tail recursive functions? yes, are, call return value of body. however, afaik scala compiler not optimise these while loops, self-recursive functions. see does scala support tail recursion optimization? details, , how use tailcalls? workaround.

python - Django 1.8 uploading files for a specific location -

spent day searching , hope can give me answer. can please advise on how make django create file directory when uploading files according page opened. for example, need create web page flats each flat have ability files uploaded. i know how upload specific location, there way django read page opened , create directory page's name, let's say: www.comunity.com/main street/house5/flat 1 i directory created the main_street/house5/flat1 and image stored there. hope makes sense. currently models.py # -*- coding: utf-8 -*- django.db import models class document(models.model): docfile = models.filefield(upload_to='documents/%y/%m/%d') and forms.py class documentform(forms.form): docfile = forms.filefield( label='pasirinkite dokumenta' ) views.py from newsletter.models import document newsletter.forms import documentform def main_street_6_flat_1(request): # handle file upload if request.method == 'post': ...

Allow user to zoom in but not out on mapview region - iOS Objective-C -

when mapview loaded, set mapregion following: mkcoordinateregion region = mkcoordinateregionmakewithdistance(location.coordinate, 700, 700); [self.mapview setregion:region]; i want user able zoom in on region, not zoom out past it. what best way of going doing this? unfortunately, mkmapviews bit limited solution might out. ios - how limit mapview specific region?

Source of Node<Object> in the Visual Studio memory snapshot -

Image
i doing memory profiling application using visual studio diagnostic tool. find there node takes lot of memory (based on inclusive size diff. (bytes). (see below #1). , when click on first instance of node, 'referenced objects', see node referencing other node. , see 'overlapped data' in attribute. how can find out creating these node mscorlib.ni.dll. the weapon of choice when rooting through these .net framework objects decompiler. use reflector, there others. you see opaque node<t> object back. type search box, out pops few types use it. in system.collections.concurrent namespace. well, no further, profiler told one. stack<t> class in system.collections.concurrent namespace that's storing nodes . your profiler told there one stack<> class object owns these objects. good, narrows down single object. happens have 208 elements. hmm, well, not much, it? that's not have stop, stack<> class pretty usele...

Disable `lint` in Android gradle -

from android tools project site's android gradle plugin user guide i'm aware it's possible prevent android's lint aborting build using: lintoptions { abortonerror false } i'm aware lint can disabled release builds: lintoptions { checkreleasebuilds false } however, possible disable lint when running e.g. gradle assembledebug ? i'm aware of risks , particular project wasting fair amount of time given build flavors have.

javascript - Extending style object in react.js -

i'm using react.js , manage of style attributes via react, too. if have a, example, success , error button want apply different background color them. right now, i'm doing jquery's extend function: <span style={$.extend({background: 'forestgreen'},this.state.buttonstyle)}></span> but i'm wondering if there better , maybe more readable solution this. advice? if use transpiler implements spread property proposal (such babel), can write style={{...this.state.buttonstyle, background: 'forestgreen'}} instead. whether thats "better" or more readable subjective.

java - iText - Missing background color in table with rowspan and page break -

Image
i'm using flying-saucer-pdf-itext5 (v 9.0.7) , itext (v 5.5.6) generate pdf given xhtml file. have big table in xhtml couple of rowspans , css style (background color). simplified xhtml snippet: <tr align="right"> <th align="left" rowspan="16" style="background: silver;">united kingdom</th> <th align="left" style="background: silver;">ambleside</th> <td>38,726</td> <td>30,546</td> </tr> this style applied correctly rowspans, except 1 - split 2 pages page break (see picture) . what i'm doing wrong? or bug in flying-saucer / itext?

'this' vs $scope in AngularJS controllers -

Image
in "create components" section of angularjs's homepage , there example: controller: function($scope, $element) { var panes = $scope.panes = []; $scope.select = function(pane) { angular.foreach(panes, function(pane) { pane.selected = false; }); pane.selected = true; } this.addpane = function(pane) { if (panes.length == 0) $scope.select(pane); panes.push(pane); } } notice how select method added $scope , addpane method added this . if change $scope.addpane , code breaks. the documentation says there in fact difference, doesn't mention difference is: previous versions of angular (pre 1.0 rc) allowed use this interchangeably $scope method, no longer case. inside of methods defined on scope this , $scope interchangeable (angular sets this $scope ), not otherwise inside controller constructor. how this , $scope work in angularjs controllers? "how this , $scope work in angularjs controllers?...

oauth 2.0 - How to use google identity toolkit without importing users -

is there workaround google identity toolkit without importing users identity server still can use using google identity toolkit. here example trying : let there identity provider entity (idp) , entity service provider server (sp),idp not allow 1 export there users due security can set trust service provider can allow login using there credentials without exposing there users on other system. so best workaround using google identity toolkit can allow me use without importing users in google identity toolkit still can login party want bare minimum configuration. basically want federation without exporting users system still want connect them using trust agreement between parties can provide them service using existing user profiles 1 having either on system or enterprise or of our partners. does of google tools or technology gives 1 channel can use above user case or work around if there use google identity toolkit avoid exporting or registering user on 2 different systems. ...

javascript - Adding a discount code to paypal button -

i'm trying add discount code paypal button, javascript works , says discount code valid isn't taking discount off amount when click buy button pay. can me please <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <p>please click on link pay</p> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="business" value="<?php echo c_our_email; ?>" /> <input type="hidden" name="first_name" value="<?php echo strfordisp($ofirstname); ?>" /> <input type="hidden" name="last_name" value="<?php echo strfordisp($olastname); ?>" /> <input type="hidden" name="address1" value="<?php echo strfordisp($theorder["oaddress"]); ?>...

c# - Doesn't Redirect to ForgotPasswordConfirmation -

this question has answer here: mvc4 .net 4.5 async action method not redirect 2 answers [authorize] public class accountcontroller : controller { [allowanonymous] public actionresult login(string returnurl) { viewbag.returnurl = returnurl; return view(); } // // post: /account/login [httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult login(loginviewmodel model, string returnurl) { if (modelstate.isvalid) { // find user username first var user = await usermanager.findbynameasync(model.email); if (user != null) { ...

c++ - Container of sets using non-default comparison predicate -

i create std::map<t1, std::set<t2> > set s use non-default comparator. example, if declaring set on own, declare as: std::set<int,bool(*)(int,int)> s (fn_pt); where fn_pt function pointer. in example, when add new key std::map , set constructed non-default comparator. such thing possible? to further complicate things, compiler not support c++11, can accept solution not require c++11; however, if there c++11 way of doing this, interested in seeing well. since can use functor should able use: struct compare { bool operator () (int lhs, int rhs) { return lhs - 10 < rhs; } }; int main() { std::map<int, std::set<int, compare> > data; } each new set created in map default constructed type specified in template parameters.

c++ - libcurl automatically replacing line feed with line feed + carriage return -

as title says when downloading , saving libcurl replacing lf lf + cr. fine text documents. binary disaster. tried curl_easy_setopt(curl, curlopt_crlf, 0l); how disable thing. i'm running on windows , curl 7.40.0 #include <iostream> #include <curl/curl.h> using namespace std; curl *curl; curlcode res; size_t file_write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { fwrite(ptr,size,nmemb,(file *)userdata); return nmemb; } int main(void) { file * pfile; pfile = fopen ("myfile.png","w"); curl = curl_easy_init(); curl_easy_setopt(curl, curlopt_url, "http://www.dilushan.tk/media/128px_feed.png"); curl_easy_setopt(curl, curlopt_followlocation, 1l); if (pfile!=null) { curl_easy_setopt(curl, curlopt_writedata, pfile); curl_easy_setopt(curl, curlopt_writefunction, file_write_callback); res = curl_easy_perform(curl); } fclose (pfile); return 0; } ...

Matrix scale video on TextureView Android -

Image
i'm trying play video exoplaye on textureview . in order scale , crop video fit view use matrix. custom view extends `textureview' here code: @override public void onvideosizechanged(int width, int height, float pixelwidthheightratio) { updatetextureviewsize(width, height); log.v("exo", "onvideosizechanged() " + width + "x" + height); } private void updatetextureviewsize(float videowidth, float videoheight) { float viewwidth = getwidth(); float viewheight = getheight(); float scalex = 1.0f; float scaley = 1.0f; float viewratio = viewwidth / viewheight; float videoratio = videowidth / videoheight; if (viewratio > videoratio) { // video higher view scaley = videoheight / videowidth; } else { //video wider view scalex = videowidth / videoheight; } matrix matrix = new matrix(); matrix.setscale(scalex, scaley, viewwidth / 2, viewheight / 2); settrans...

android - How often should my app update user's location using GPS? Is every 1 second overkill or fine? -

using google maps api create route while app open. right now, updating every second. fine? how google maps app update example? kill battery/hog cpu if have location updated every 1 second? thank you once second fine. cannot save battery updating once in 5 seconds. save battery have request in lower frequence, once in 20 minutes. it depends of application how accurate tracking must , how need location.

c# - How to reroute click event to a double click? -

i'm trying reroute click event act double click instead. example if double click textbox select text can edit, want single click same. is possible reroute events , if how 1 so? thanks! inside single click event handler, following: var newmouseevent = new mousebuttoneventargs(mouse.primarydevice, 0, mousebutton.left) { routedevent = control.mousedoubleclickevent }; mytextbox.raiseevent(newmouseevent);

vb.net - VB setting a string to nothing -

this question has answer here: nothing = string.empty (why these equal?) 4 answers difference between c# , vb.net string comparison 2 answers the code below returns true when expected return false . why return true ? expect nothing set value of string null, not empty (according msdn ) codeingground sample module vbmodule sub main() dim x string x = nothing console.writeline(x = string.empty) end sub end module nothing (visual basic) represents default value of data type. reference types, default value null reference. ***edit**** nothing = string.empty (why these equal?) nothing in vb.net default value type. language spec says in section 2.4.7: nothing special literal; not have type , convertible types in type sys...

How to configure solr dataimport handler to parse wikipedia xml document? -

so have done far. i have added request handler in solrconfig.xml follows: <requesthandler name="/dataimport" class="org.apache.solr.handler.dataimport.dataimporthandler"> <lst name="defaults"> <str name="config">wiki-data-config.xml</str> </lst> </requesthandler> in same configuration directory have created file wiki-data-config.xml contains following, <dataconfig> <datasource type="filedatasource" encoding="utf-8" /> <document> <entity name="page" pk="id" processor="xpathentityprocessor" stream="true" foreach="/mediawiki/page/" url="/home/tanny/downloads/data/wiki/enwiki-20150702-stub-articles8.xml" flatten="true" > <field column="id"...

java - Share POJO Entity Data Classes between Android and Spring projects -

how can reference, add, link, depend on java classes defined in different project or library without copy / paste? for: android studio intellij idea android studio androidprojectroot/settings.gradle before include ':app' after include ':app', ':common' project(':common').projectdir = new file('../common') androidprojectroot/app/build.gradle before apply plugin: 'com.android.application' android { ... } dependencies { } after apply plugin: 'com.android.application' android { ... } dependencies { compile project(':common') } then... tools -> android -> sync project gradle files allows android studio project reference external project (at same directory level androidprojectroot/, without making copy of java library inside android project. library project / module you'll need basic build.gradle library/module. following suffice. dependencies example (onl...

Color coding parentheses and brackets in Visual Studio -

Image
excel performs color coding of parentheses according "depth": is such thing possible in visual studio (any version)? know how modify color of parentheses , how brace matching, i'm asking different (and permanent) colors parentheses (and braces, etc) according depth. i know isn't possible vanilla visual studio, there addin out in wild this? "rainbow braces" implemented extension viasfora .

Unexpected result of matrix multiplication in R -

r program not return expected matrix multiplication a<- c(0,1,1,0) a<- matrix(a,2,2) b<- matrix(c(1,2,3,4),2,2,byrow=true) a*b gives final answer matrix(c(0,2,3,0), ncol = 2, byrow=true) : [,1] [,2] [1,] 0 2 [2,] 3 0 but actual answer should matrix(c(3,4,1,2), ncol = 2, byrow=true) [,1] [,2] [1,] 3 4 [2,] 1 2 you can use either %*% or crossprod matrix multiplication > %*% b [,1] [,2] [1,] 3 4 [2,] 1 2 > crossprod(a, b) [,1] [,2] [1,] 3 4 [2,] 1 2 note result 2x2 matrix, if want vector in example, use matrix(crossprod(a, b), ncol=1)

node.js - npm local modules vs prod -

we developping 2 modules depending on one. a -› b , c -› b i dug solutions available now: from projects a, b npm link ../projectc cool: it's symlink, changing file in c passed on , b not cool: it requires ../projectc in parent folder (no npm install on prod) it not show in package.json so need fiddle postinstall in package.json or npm install ../projectc cool: it's in package.json not cool: it requires ../projectc in parent folder (no npm install on prod) we have npm install everytime change c so solution npm link . you can, in project c npm link (make sure have package.json ). then in projects , b: npm link module-projectc also add dependency in package.json then able code comfortably while in development, , npm install in production scenarios.

angularjs - Can I manage dynamic controllers based on $stateParams? -

i'm working ui-router. know of set dynamic templateurl i'd manage dynamic controller. here i'm looking for: $stateprovider.state('town.building', { url: "/building?id", templateurl: function ($stateparams) { // working dynamic templateurl if ($stateparams.hasownproperty('id')) { switch (number($stateparams.id)) { case 1: return "views/factory.html"; /* case 2, case 3, etc. */ default: return null; } } return null; }, controller: function ($stateparams) { // dynamic controller ? if ($stateparams.hasownproperty('id')) { switch (number($stateparams.id)) { case 1: return "myfirstcontroller"; /* case 2, case 3, etc. */ default: return "defaultcontroller"; } } retur...

apache pig - Using Hive UDF's in Pig -

is there reason not use hive udf's in pig 0.15? i'm thinking performance, if there other reasons i'd happy hear them. for example, have simple java implementation of lpad use. should bother keeping it, or can use hive version? hive udfs supported in pig 0.15 version. see below. http://hortonworks.com/blog/announcing-apache-pig-0-15-0/

Adding Buttons to slide, HTML and Javascript -

i have found following code how 1 go adapting code in form of adding buttons go forwards , backwards in slideshow. explaining: slide forward: make button following onclick event <button onclick="slideit()">forward</button> if don't want slide change every 2 , halve seconds, put // before line: settimeout("slideit()",2500); or delete it. slide backward: <button onclick="slideback()">back</button> function sliding backward: var numslides = ; function slideback() { document.images.slide.src = eval("image"+step+".src"); if (step > 1) { step--; } else { step=numslides; } } you need set numslides number of slides have. summary: html: <button onclick="slideback()">back</button> <button onclick="slideit()">forward</button> script: var numslides = ; var autoplay= ; function slideback() { ...

Android and iOS: storage of credit card data -

for mobile applications on android , ios need store credit card information had opportunity them autofill forms. possible keep data secure? just don't it, far more complex think , risky. take @ https://stackoverflow.com/a/3002237/4739608 .

asp.net - OWIN WebApi Entity Framework with OAuth Identity -

i'm experimenting self hosted owin webapi/entity framework project i've created startup class , configured both owin , webapi using useoauthbearerauthentication , useoauthauthorizationserver provider defined class deriving oauthauthorizationserverprovider provider = new applicationoauthserverprovider() // :oauthauthorizationserverprovider this class overrides public override async task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) {} validate user creates claimsidentity returning token encoding associated claims in case nameidentifier, name , role (role "admin") everything works expected , token returned. i'd take advantage of associated claims inside apicontroller. problem user.identityobject has authentiationtype isauthenticated , name properties associated claims not there , can't name property. see using [authorize (roles="admin")] i'm able access apicontroller role claim availabl...

php - How to upload bulk records in CAKEPHP -

a 4 column dashboard 10 rows provided wherein user can enter details follows: column 1 – file category column 2 – file type column 3 - file reference column 4 – upload file (any type) upload button– uploads details of documents entered simultaneously i unable upload records in database last recording saving in database kindly me usercontrolle.php (my controller) <?php app::uses('appcontroller', 'controller'); class filescontroller extends appcontroller { public $helpers=array('html','form'); public $components = array('requesthandler'); /*function display files details*/ public function index() { $this->set('files', $this->file->find('all')); } /*function add file record database */ public function add() { if ($this->request->is('post')) { $this->file->create(); if(empty($this->data[...

jsf - How to handle authentication/authorization with users in a database? -

currently, working on web project using jsf 2.0, tomcat 7 , mongodb. have big question of how handle session management , authentication/authorization users in database. the structure want follows: logged in users can create events , can see created events. create.xhtml --> logged in users. events.xhtml --> public everyone. the basic structure i'm planning is: check if page requires logged in user (e.g. create.xhtml ) if yes, check if user logged in if user not logged in, go login.xhtml if logged in, come requested page keep "user logged in" information unless user clicks log out button. (there guess @sessionscoped gets play) the question is: what less complicated way of doing this? where should use @sessionscoped annotation? in create.java or loginmanager.java ? spring security looks kind of complicated issue, need it? if yes, can explain little bit of how implementation works jsf 2.0 , mongo db? there several options. cho...

parsing - Parse data not appearing in iOS 9 Beta 4 -

since updating ios 9 beta 4 seems our app can no longer access data in our parse database - known issue? others experiencing? any solution? thanks! try adding domain exception in *.plist file: <key>nsapptransportsecurity</key> <dict> <key>nsexceptiondomains</key> <dict> <key>files.parsetfss.com</key> <dict> <key>nsincludessubdomains</key> <true/> <key>nstemporaryexceptionallowsinsecurehttploads</key> <true/> <key>nstemporaryexceptionminimumtlsversion</key> <string>tlsv1.1</string> </dict> </dict> </dict>

java - How to roll back a database change with Liquibase using classpath -

my application using liquibase manage database changes. sets liquibase so: @bean(name = "liquibase") public springliquibase liquibasedata() { final springliquibase liquibase = new springliquibase(); liquibase.setdatasource(datasource); liquibase.setchangelog("classpath:/db/changelog/db.changelog-master.xml"); return liquibase; } it has single changeset. when changeset gets applied running application, record inserted databasechangelog expected filename of classpath:/db/changelog/0.0.1/db.changelog.xml when execute liquibase rollbackcount 1 , response liquibase rollback successful , change did not rolled back. after manually rolling change (deleting table created changeset), liquibase update . update successful, filename db/changelog/0.0.1/db.changelog.xml . execute liquibase rollbackcount 1 , , change rolled expected. this liquibase.properties : driver: oracle.jdbc.driver.oracledriver classpath: ../../../../../client-ui/build/libs/...

c# - MvvmCross backward navigation on Windows Phone 8.1 -

i have windows phone silverlight 8.1 mvvmcross 3.5.1 based application navigates forward , backward between views flawlessly. to navigate forward, using mvxviewmodel.showviewmodel() api. works well. navigate backwards, use button on phone , works well. i making windows phone 8.1 equivalent of same application use wallet features. navigation forward works expected. however, when click on button on phone, application exits. this entire content of app.xaml.cs windows phone 8.1 app. /// <summary> /// provides application-specific behavior supplement default application class. /// </summary> public sealed partial class app : application { private transitioncollection transitions; /// <summary> /// initializes singleton application object. first line of authored code /// executed, , such logical equivalent of main() or winmain(). /// </summary> public app() { thi...