Posts

Showing posts from January, 2010

c++ - Error: Undefined reference symbol to cv::VideoCapture::~VideoCapture(), DSO missing from command line -

i trying run opencv code on raspberry pi following error /usr/bin/ld: cmakefiles/main.dir/main.o: undefined reference symbol 'cv::videocapture::~videocapture()' /usr/local/lib/libopencv_videoio.so.3.0: error adding symbols: dso missing command line dso stands "dynamic shared object" it's linking error. see this: opencv 2.4.7 error adding symbols: dso missing command line add -lopencv_features2d compile path.

javascript - Watch new file in gulp and browsersync issue -

i'm use browsersync reload browser when file changed. , it's work perfect. when create new file such html - scss - js bowsersync don't work !!! how fix problem? gulpjs : // browser sync gulp.task('browser-sync', function() { browsersync({ injectchanges: true, notify: false, server: "app" }); }); gulp.task('default',['sass','scripts', 'browser-sync'], function(){ gulp.watch("app/**/*.html").on('change', reload); gulp.watch('app/img/*.*', ['bs-reload','images']); gulp.watch('src/scss/**/*.scss', ['sass']); gulp.watch('src/js/**/*.js', ['scripts','uglify']); }); turns out solution rather simple. don't use gulp.watch. use browsersync.watch instead. i'm going reorganize task, , add config. helps in instance: gulpfile.js // ---------------------...

SQL query to fetch data from last visit of particular column -

i have table columns regno,dt,visitno , symptom_code. i'd fetch data last visit of regno. please suggest sql query. every dbms supports this: select * tab t1 dt = ( select max(dt) tab t2 t1.regno = t2.regno) most dbmses support windowed aggregate functions, easier write , more efficient: select * ( select ... ,rank() on (partition regno order dt desc) rnk tab ) dt rnk = 1

asp.net mvc - Pass method dependency in MVC controller action Method -

how can pass dependency using unity, mvc controller action method ? for example, if have post action method dependency of itestrepository type, injected through method injection ? not want testrepository instantiated withing action method. public actionresult savedata(itestrepository irepoinstance) { var save = irepoinstance.savedata(); return view(); }

javascript - Error:Abnormal build process termination: Exception in thread "main" java.lang.NoSuchMethodError: -

i started android studio in newly updated os x (mavericks now). now in android studio (also updated btw) message "error running git" error:abnormal build process termination: exception in thread "main" java.lang.nosuchmethoderror: org.apache.log4j.propertyconfigurator.configure(ljava/io/inputstream;)v @ org.jetbrains.jps.cmdline.buildmain.initloggers(buildmain.java:339) @ org.jetbrains.jps.cmdline.buildmain.(buildmain.java:67) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.jetbrains.jps.cmdline.launcher.main(launcher.java:58) have: two different versions of log4j included in project your log4j.jar file duplicated . the first more likely hope works ;-) ...

android - Large text in default AlertDialog freezes screen -

i want display large message default alertdialog following code. public void showconditions(view v) { final alertdialog alertdialog = new alertdialog.builder(this).create(); alertdialog.settitle("policy terms"); alertdialog.setmessage("very large text..."); alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { alertdialog.cancel(); } }); alertdialog.show(); } code working fine shows dialog after 2 or 3 seconds , when pressed button , freezes screen too. i tried display text new activity , happens same: - freeze screen , takes 2 seconds display it. i tried show loader(progressbar) inform user being open soon. - happens same. i can't find solution. i appreciate ideas. thanks.

java - Does spring requires JTA TX manager when deployed in Tomcat -

i have web application, deployed in tomcat. app depends on 1 spring pojo app jar, whcih available in classpath. spring pojo app, contains dao's , few services, i'm accessing these dao's , services in web app beans, loading spring context using classpathxmlapplicationcontext. the serivces in spring app uses daos , in case both apps accessing same db. spring pojo app uses hibernatetransactionmanager. for scenario, hibernatetxmanager good, or need gor jta? jta useful when want enlist 2 or more datasources in sam global transaction. in case should have services use daos , web beans use services , spring application design decision. for connection pooling, advice take on hikaricp , fastest 1 on market .

Swiftmailer in Yii2 - Unable to send email -

i'm using basic yii2 template , swiftmailer send email.. here code config/web.php : 'mailer' => [ 'class' => 'yii\swiftmailer\mailer', // send mails file default. have set // 'usefiletransport' false , configure transport // mailer send real emails. 'usefiletransport'=>'false', 'transport' => [ 'class' => 'swift_smtptransport', 'host' => 'smtp.gmail.com', 'username' => 'myemail@gmail.com', 'password' => 'password', 'port' => '587', 'encryption' => 'tls', ], ], and controller code is: $fname = yii::$app->request->post('fname'); $email = yii::$app->request->post('email'); ...

android - Cordova build returns missing plugin.xml -

when build cordova project warning message as: missing file: /home/vijay/workspace/repos_temp/quicktraq_android/plugins/nl.x-services.plugins.toast/plugin.xml missing file: /home/vijay/workspace/repos_temp/quicktraq_android/plugins/cordova-plugin-device-rotation-vector/plugin.xml this happens when add plugin or remove plugin . this happens warning when add plugin or build project when remove plugin error occurs error: enoent, no such file or directory '/home/vijay/workspace/repos_temp/quicktraq_android/plugins/com.grumpysailor.cordova-plugin-device-rotation-vector/plugin.xml' @ object.fs.opensync (fs.js:439:18) @ object.fs.readfilesync (fs.js:290:15) @ object.module.exports.parseelementtreesync (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/util/xml-helpers.js:121:27) @ /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/dependencies.js:56:35 @ array.foreach (native) ...

parse.com - Can not retrieve data from local database after saving it from Parse in ios -

i have logged in here code , after have saved data in local db using pinning . [pfuser loginwithusernameinbackground:name password:pass block:^(pfuser *user, nserror *error) { if (user) { // stuff after successful login. [user pininbackground];//save in local db nslog(@"user logged in"); //fetching profile image parse pffile *userimagefile = user[@"profilepic"]; [userimagefile getdatainbackgroundwithblock:^(nsdata *imagedata, nserror *error) { if (!error) { uiimage *proimage = [uiimage imagewithdata:imagedata]; self.pr...

java - Switching between log4j configs -

i've implemented spring profiles, in web.xml added default profile: <context-param> <param-name>spring.profiles.default</param-name> <param-value>prod</param-value> </context-param> and in applicationcontext.xml can switch between config file use: <beans profile="dev"> <context:property-placeholder location="classpath*:meta-inf/spring/dev.properties"/> </beans> <beans profile="prod"> <context:property-placeholder location="classpath*:meta-inf/spring/prod.properties"/> </beans> and i've made mvn jetty:run use dev profile: <plugin> <groupid>org.eclipse.jetty</groupid> <artifactid>jetty-maven-plugin</artifactid> <version>9.2.10.v20150310</version> <configuration> <webappconfig> <contextpath>/${project.artifactid}</contex...

loopbackjs - From which file do I send a push notification in strongloop? -

i trying set push notifications strongloop. don't understand file code below lives in. docs don't say, confusing newbies. i understand have add push component loopback restful api application, have done. how reference push component restful api app? where's 'glue'? http://docs.strongloop.com/display/public/lb/push+notifications var badge = 1; app.post('/notify/:id', function (req, res, next) { var note = new notification({ expirationinterval: 3600, // expires 1 hour now. badge: badge++, sound: 'ping.aiff', alert: '\ud83d\udce7 \u2709 ' + 'hello', messagefrom: 'ray' }); pushmodel.notifybyid(req.params.id, note, function(err) { if (err) { // let default error handling middleware // report error in appropriate way return next(err); } console.log('pushing notification %j', req.params.id); res.send(2...

jquery - How to toggle two buttons on mouse hover? -

i've 2 buttons: 1 - follow 2 - unfollow at first glance follow button displayed , when hover on follow button, want make follow button disappear , unfollow button appear, after once hovered on unfollow button want follow button appear , unfollow button dispear, how do it? feed backs welcomed. html code <div class="btn-follow">follow</div> <div class="btn-unfollow">unfollow</div> css code .btn-follow { color: #fff; background-color: #38b7ea; padding: 5px 0; width: 100px; margin: 0 auto; border-radius: 20px; } .btn-unfollow { color: #fff; background-color: #a5becb; padding: 5px 0; width: 100px; margin: 0 auto; border-radius: 20px; } an alternative , more optimal solution said can done same button below: demo here html <button id="followunfollow" class="followunf follow">follow</button> js $(document).ready(function(){ ...

opencv - How to build a portable program by visual studio -

i using visual studio 2010 under win7-64bit build application opencv. finished development , build release version without error. run program in debug mode. move .exe file other directory in same computer. run in cmd.exe , got error warning: error opening file <../../modules/highgui/src/cap_ffmpeg_implhpp:537> guess there dependence libraries of opencv don't how solve it. final task can use .exe in computer under win7 directly. how it? found similar question here . don't have .dll file built, should solve problem? building opencv app shared libs (dlls) require dlls available (same folder or in lookup path) exe when run. if using static linking don't need of opencv dlls reachable. however , due licensing issues, ffmpeg linked dynamically even when rest of libs linked statically, , thus, need have ffmpeg dll available exe . called opencv_ffmpeg*.dll . note needed if using highgui related functionality.

php - Finding username of the last post in mysql table joining 3 tables -

i know doing qry wrong - taking on 10secs results come w/ 3000 rows of data... have 3 tables: users id username data: 1|tom 2|dick 3|harry posts id id_users data: 1|1 2|1 3|1 4|2 5|2 6|3 cronjobs id id_post id_wall data: id|id_post|id_wall 1|1|1 2|1|2 3|1|3 4|1|4 5|1|5 6|2|5 7|4|3 8|6|3 9|4|4 a user make post post put on 1 or more walls , stored in cronjobs table. id on cronjobs auto increment. need username , last post on each wall. in above example dick last person post on wall 4 post 4 harry last person post on wall 3 post 6 tom last person post on wall 5 post 2 tom last person post on wall 2 post 1 tom last person post on wall 1 post 1 here qry im using, know using in clause select inside it, killing this.... select c.id, c.id_post, c.id_wall id_wall, p.id_users user_id, u.name username cronjobs c, posts p, users u c.id in (select max(id) cronjobs group id_wall) , c.id_post = p.id , p.id_users = u.id orde...

c++ - Cross Compiling for Android on Ubuntu -

i wrote libraries product on window platform (c/c++) product , need build libraries android platform. totally new cross-compiling , relatively new linux. did searching , found helpful link android source . did repo , downloaded , synchronized source. stuck should do. took several hours download source, normal per many threads on net. here need how can cross-compile source against android? can use netbeans compiler?. host running android branch android-5.0.0_r1.0.1. (version lollipop).

c - How to use rand -- C99 version -

i writing c program , want use for : for(int i=0 ; < ; i++ ) so need use c99 version in order initialize counter of inside " ( ) " c99 version doesn't work rand() function . in fact on man page of rand() mentions : " function not part of c99 part of posix " any ideas in order avoid initializing counter before for .. //update the output of compile : warning: implicit declaration of function ‘rand_r’ [-wimplicit-function-declaration] code : array[i] = rand_r(&seed) % max + min; > array[i] type char* (i have dynamically allocated space it) thanks rand() much part of c99 standard, have make sure include correct header file. #include <stdlib.h> int main(void) { return rand() % 10; } the stdlib.h header file covered in 7.20 of c99 standard, , rand() covered in 7.20.2 . if man page stating it's not part of c99, it's incorrect. mine (under debian jessie) states: the functions r...

Chromecast not able to load and cast youtube videos in sender chrome app -

i new chromecast. trying cast videos chrome browser .i able cast mp4 videos youtube videos give error or youtube tv logo casted not actual video. you cannot cast youtube videos based on id's or of sort. can potentially write custom receiver , embed iframe youtube player in receiver not perfect solution either (for example, user won't able skip ads).

web services - FrontierLink B2B getting started -

has of tried integrating frontierlink? found in documentation 5.2 building frontierlink client 5.2.1 soap client environment must adhere following minimum requirements soap clients in order integrate frontierlink: xml 1.0 soap 1.1 http 1.0 (1.1 preferred) ssl based connection authenticated via x.509 digital certificates wsdl1.1 a web services toolkit supporting wsdl 1.1 recommended aid development. in documentation there no sample on how started. sorry asking question code connecting frontierlink? thanks! hoping can :) thank once again! may please show example of frontierlink api? may able further? just in nutshell understand when using soap api, have call apis or links application(web/mobile) , in turn api return data in form of xml. have parse data may able use in application.

Why mapPartitionsWithIndex cause a shuffle in Spark? -

Image
i'm new in spark. i'm checking shuffling issues in test application , don't know why in program mappartitionswithindex method cause shuffle! can see in picture initial rdd has 2 16mb partition , shuffle write 49.8 mb. know map or mappartition or mappartitionswithindex not shuffling transformation groupbykey see cause shuffle in spark. why? i think performing join/group operation after mappartitionswithindex , causing shuffle. you can establish modifying code. current code val rdd = inputrdd1.mappartitionswithindex(....) val outrdd = rdd.join(inputrdd2) modified code val rdd = inputrdd1.mappartitionswithindex(....) println(rdd.count)

Python- sqlalchemy.exc.ArgumentError:could not assemble any primary key columns for mapped table -

i'm using flask + alembic + sqlalchemy. want create 2 table , use it. first, run alembic script : """add table insurace_bands , insurace_discounts revision id: 39ba7ec3428 revises: 18468fbedbac create date: 2015-05-12 09:10:05.175513 """ # revision identifiers, used alembic. revision = '39ba7ec3428' down_revision = '18468fbedbac' alembic import op import sqlalchemy sa def upgrade(): op.create_table('insurance_bands', sa.column('id', sa.integer(), nullable=false), sa.column('name', sa.string(length=1024), nullable=false), sa.column('product_price', sa.numeric(precision=6, scale=2)), sa.column('monthly_price', sa.numeric(precision=6, scale=2)), sa.column('active', sa.boolean(), nullable=false, server_default='1'), sa.primarykeyconstraint('id') ...

java - Avoiding indexing HTML tags as search keywords -

i'm indexing keywords in html document, don't want index html tags. for example: <div> <!-- html code --> <span>you welcome</span> <!-- simple message searching --> <div> <h1>testing text</h1> <!-- second message --> </div> </div> expected keywords: keywords:you how can avoid html tags becoming keywords? i think need parse html , extract inner text of each tag.

winapi - Clear the text value in other App's edit control by using Excel VBA with Windows API -

rendered output markdown -1 votes comment: code alignment clear text value in other app's edit control using excel vba windows api htarget handle value of other application. [failed] ret = sendmessage(htarget, wm_setfocus, 0&, 0&) ret = sendmessage(htarget, wm_keydown, vk_control, 0) -ret = sendmessage(htarget, wm_keydown, 97, 0) ret = sendmessage(htarget, wm_keydown, vk_delete, 0) sleep (300) ret = sendmessage(htarget, wm_keyup, vk_delete, 0) ret = sendmessage(htarget, wm_keyup, 97, 0) -ret = sendmessage(htarget, wm_keyup, vk_control, 0) [failed] -const em_setsel = &hb1 -const em_replacesel = &hc2 -const em_getsel = &hb0 -htarget = findwindowex(htarget, 0&, "tplusmemou", vbnullstring) -call sendmessage(htarget, em_setsel, 0, -1) -call sendmessage(htarget, em_replacesel, 1, "") [failed] -call sendmessage(htarget, wm_keydown, vk_back, 0) -call sendmessage(htarget, wm_char, 8, 0) htarget handle v...

php - Error in mysql_fetch_array. Unable to fetch the records through while loop -

i trying fetch values of updated records dp. let me brief this- 1.i have 2 while loops ,one displaying records database , second fetched after edit operation. 2.after editing 1 of fields record should updated in database [i have updated record/records in db ] problem updating in database [ have checked db update record] records not displayed of updated records. think not enter while loop of update query. please suggest solution. if(isset($_post['recruiter_s_by_code']) { //some code here...the query here being sucesss //select statement here.. } if(isset($_post['recruiter_s_by_mail']) { //some code here...the query here being sucesss //select statement here.. } if(isset($_post['recruiter_s_by_name']) { //some code here...the query here being sucesss //select statement here.. } if(isset($_post['recruiter_s_by_code']) || isset($_post['recruiter_s_by_name']) || isset($_post['recruiter_s_by_mail'])) { $result=mysql_query($...

sql - What's the best way to sanitize destroy_all - Rails -

i have following controller in rails : class foocontroller < applicationcontroller def delete_foo(bar): foo.destroy_all("foo = '#{@bar}'") is foo.destroy_all("foo = ?", @bar) always valid? destroy_all works on relation. why not do foo.where(foo: bar).destroy_all

find - Delete directories with specific files in Bash Script -

i delete specific files if existed directories contain these files. know files wipe not directories. far, i'm new in bash scripting, think of : find ./ -type f -name '*.r*' -print0 | xargs -0 rm -rf &> log_del.txt find ./ -type f -name '*.c*' -print0 | xargs -0 rm -rf &>> log_del.txt at moment, files named specific extensions *.r* , *.c* deleted. directories still remaining , subdirectories in it, if existed. thought of option -o in find delete in 1 line : find ./ -type f \( -name '*.r*' -o -name '*.c*' \) -print0 | xargs -0 rm -rf &> log_del.txt how can this? , see log_del.txt file empty... :-( it looks want remove empty directories, recursively. find . -type d -delete -delete processes directories in child-first order, a/b deleted before a. if given directory not empty, find display error , continue.

angularjs - How do I remove watchers created by a template which was added and removed dynamically using $compile? -

we have directive allows developers specify own template , data used scope bound template using $compile. template have angular expressions create watchers. when element's content represented template , scope removed dom tree, how remove watchers created it? this link proves watchers stay when dom represent removed tree. clicking compile button first time compile angular template , attach dom tree. second time button clicked, empty element previous template added , add newly compiled template. index.html <!doctype html> <html ng-app="app"> <head> <script data-require="jquery@1.7.2" data-semver="1.7.2" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script data-require="angular.js@1.2.6" data-semver="1.2.6" src="https://code.angularjs.org/1.2.6/angular.js"></script> <link rel="stylesheet" href="sty...

html - How to make the div width fit the table which inside the div? -

if table inside div , width of table uncertain, can wider screen width, how make div containing table adjust table width? since div has been set padding: 10px , when table exceeds screen width, padding-right turns invisible. here code: <div class="panel-body"> <table class="table table-hover table-bordered"></table> </div> i found method. .panel-body{ display: inline-block; padding: 10px; } the key why can work "display".you learn differences block,inline,and inline-block. hope helps

javascript - Building a calculator using JQuery, Issues with multiple calculations -

i have been building calculator jquery . clear button doesn't work after multiple calculations , further calculations yield incorrect results. i looking improve solution correct multiple calculations problem running into. my snippet below. var alpha = 0; var bravo = 0; var charlie = 0; $(document).ready(function(){ $('#button1').click(function(){ $('#output').val($(this).val()); }); $('#button2').click(function(){ $('#output').val($(this).val()); }); $('#button3').click(function(){ $('#output').val($(this).val()); }); $('#button4').click(function(){ $('#output').val($(this).val()); }); $('#button5').click(function(){ $('#output').val($(this).val()); }); $('#button6').click(function(){ $('#output').val($(this).val()); }); $('#button7').click(function(){ $('#output').val($(this).val()); }); $('#butto...

c# - Locking across different threads in an ASP.NET WebAPI -

i've got scenario require cache information webapi temporarily when first called. same parameters api can called few times second. due performance restrictions don't want each call fetching data , putting memory cache i've implemented system semaphores try , allow 1 thread initialize cache , allow rest query cache. i've stripped down code show example of i'm doing currently. private static memorycacher memcacher = new memorycacher(); private static concurrentdictionary<string, semaphore> dictionary = new concurrentdictionary<string, semaphore>(); private async task<int[]> doathing(string requesthash) { // check existing cached result before hitting dictionary var cachevalue = memcacher.getvalue(requesthash); if (cachevalue != null) { return ((cachedresult)cachevalue).cheeseburgers; } ...

User Input in a Java GUI -

i have been trying figure out should use user input in gui. want user input text gui , have program save text can use later. have basic understanding of programming gui's. appreciated! you can use jtextfield or joptionpane.showinputdialog . question how can input value swing? or asking can use?

javascript - SignalR OnConnected & OnDisconnected with Signin & Signout -

my scenario construct website custom authentication, there's menu transition mouse click, , because of custom tool, use window.location change page; but login , out been used calculate daily report of each login/out user, have prevent user close browser tab or close button; and search, there's no proper method distinguish reload , close, tried use signalr deal these situation. is there idea detect user's onconnected & ondisconnected triggered reload or close tab/browser? please try one, think should helpful you. javascript window.onbeforeunload = function(e){ var msg = 'are sure?'; e = e || window.event; if(e) e.returnvalue = msg; // ondisconnected event here (signalr) } jquery $(window).unload(function() { // ondisconnected event here (signalr) });

assembly - Encoding the multi-byte no-operation instruction (x86/x64) -

this instruction on page 1018 of intel x64 reference manual. here's looks like: opcode instruction description 90 nop 1 byte no-operation instruction. 0f 1f /0 nop r/m16 multi-byte no-operation instruction. 0f 1f /0 nop r/m32 multi-byte no-operation instruction. i read somewhere max no-op length 9 bytes. no-op length in 16/32 bit register or memory address or encode bunch of zeroes myself , if how r/m16 or r/m32 apply? from xed: xed64 -64 -e nop mem4:eax,eax,1,00000000 operand order: mem0 encodable! 670f18a40000000000 .byte 0x67,0x0f,0x18,0xa4,0x00,0x00,0x00,0x00,0x00 the advantage of using 9 byte nop reduce strain decoder, can decode 4 instructions per cycle. , nop technically instruction.

Akka.NET TestKit synchronous behavior -

i have following c# code test akka.net actor's behavior. statement productactor.tell(new changeactivestatus(true)); expected blocking call (testkit makes synchronous call per blog ) i'm seeing returns immediately. result, second test fails although activestatus changed later. [testmethod] public void productactorunittests_checkfor_activestatuschanged() { var productactor = actorofastestactorref<productactor>(); assert.istrue(productactor.underlyingactor.activestatus == false, "the initial activestatus expected false."); productactor.tell(new changeactivestatus(true)); assert.istrue(productactor.underlyingactor.activestatus == true, "the new activestatus expected true."); } ****** update ***** the following code thread.sleep(10000) succeeds: [testmethod] public void productactorunittests_checkfor_activestatuschanged() { var productactor = actorofastestactorref<productactor>(); assert.istrue(productactor.und...

javascript - mocha-phantomjs xunit reporter and file output not working -

using $mocha-phantomjs -r xunit -f outputfile.xml mypage.html ----> generating console output in xml format not writing in output file. on other hand : $mocha-phantomjs -r json -f outputfile.json mypage.html -----> working expected. okay thing has been resolved part of issues in github repo of mocha-phantomjs. here link go issue

json - How to export DataFrame to_json in append mode - Python Pandas? -

i have existing json file in format of list of dicts. $cat output.json [{'a':1, 'b':2}, {'a':2, 'b':3}] and have dataframe df = pd.dataframe({'a':pd.series([1,2], index=list('cd')), \ "b":pd.series([3,4], index=list('cd')}) i want save "df" to_json append file output.json: df.to_json('output.json', orient='records') # mode='a' not available to_json * there append mode='a' to_csv, not to_json really. the expected generated output.json file be: [{'a':1, 'b':2}, {'a':2, 'b':3}, {'a':1, 'b':3}, {'a':2, 'b':4}] the existing file output.json can huge (say tetabytes), possible append new dataframe result without loading file? http://pandas.pydata.org/pandas-docs/dev/generated/pandas.dataframe.to_json.html http://pandas.pydata.org/pandas-docs/dev/generated/pandas.dataframe.to_csv...

javascript - Rendering XML in a new window in Chrome -

Image
i have used following code displaying xmlstring retrieved ajax call in new window: window.open('data:text/xml,' + encodeuricomponent( xmlstring ) ); it working in firefox need make work in chrome well. can not have specific xslt file transformation, because xmlstring have dynamic structure, different each time call controller. xml string want show in new window. can advise? update: error in chrome: this page contains following errors: error on line 1 @ column 65425: couldn't find end of start tag loca below rendering of page first error. and see messedup string not xml. i not know if related xml structure found link says above code working in firefox or opera. again cannot use xslt not know do. render xml document (obtained through ajax call) new window thank helping me! ;) if type following console in chrome, window.open('data:text/xml,' + encodeuricomponent( "<a><b><c/><d/></b><e/></a...

SignalR JavaScript client universal trigger -

i need attach event every hub.client method. example: hub.client.dosomething = function (e) { afunction(e); }; hub.client.dosomethingelse = function (e) { afunction(e); }; is there way attach afunction() client methods on client level, without placing function in each client method? i don't know such callback available directly on hub proxy, use received callback on connection object. (see list of connection lifetime events , received definition ) be aware received callback called every time data received connection, means, if have multiple hubs, invoked when of hub send data client. means, have inspect data received in callback , decide, if should process data (if belongs given hub, if real message, or signalr internal message).

ios - Return view to original position after animation -

i've made when user taps on text field, view shifts fields still visible while user typing. works great, after keyboard dismissed, instead of returning original position, view slides down far (leaving small blank black bar @ top). know how can restore view original position? here's code: - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. _userfield.returnkeytype = uireturnkeydone; [_userfield setdelegate:self]; _passfield.returnkeytype = uireturnkeydone; [_passfield setdelegate:self]; uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(dismisskeyboard)]; [self.view addgesturerecognizer:tap]; } - (void)dismisskeyboard { [_userfield resignfirstresponder]; [_passfield resignfirstresponder]; } -(void)textfieldshouldreturn:(uitextfield *)textfield { [textfield resignfirstresponder]; } -(void)textfielddidbeginediting:(uitextfield *)...

netlogo - Perspective based ranking? -

i have program each peer has own ranking system of other peers, best way implement netlogo? normally, solve 2d list: [[turtle 1, score], [turtle 2, score], ...] but seems troubling in netlogo. code creating , modifying 2d list: to test clear-all crt 10 ;create list of turtles let agents-list [self] of turtles ;create empty list, top level of twod list let twod-list [] ;populate twod-list: [[turtle 0, 0], [turtle 1, 0], ...] foreach agents-list [ set twod-list (lput (list ? 0) twod-list) ] show twod-list repeat 5 [ ;change value in twod-list let rand-index random (length twod-list) ;select random index ;the next line makes huge headache, have select list @ top level replace, , select list @ lower level replace it. ;this entire line of code adding 1 element set twod-list (replace-item rand-index twod-list (replace-item 1 (item rand-index twod-list) (item 1 (item rand-index twod-list) + 1))) show twod-list ] end what els...

How to display all posts with all its comments - Ruby on Rails -

i'm new rails , don't know how achieve in rails. might stupid question. not covered in ror codecademy course did , not fint answer elsewhere. so have 2 tables, posts , comments have one-to-many relationship. 1 post has many comments. i want display post comments underneath. correct way this? there 2 ways this: first : can way in post controller action ( suppose :index ) do: def index @posts = post.all end and in index.html.erb <% @posts.each |post|%> # post attribute name etc <% post.comments.each |comment|%> # post attribute name etc <% end %> <% end %> second : in post controller action do: def index @posts = post.all.includes(:comments) end and in index.html.erb <% @posts.each |post|%> # post attribute name etc <% post.comments.each |comment|%> # post attribute name etc <% end %> <% end %> difference in above 2 ways in first 1 there data base call when ...

javascript - toggle button with font awesome and jquery -

i thought going simple, having bit of hard time getting work. able toggle once using .show , .hide, not able toggle back. all appreciated. here code: <div class="middle"> <i class="fa fa-toggle-on fa-2x active" id="on" style="display:none;"></i> <i class="fa fa-toggle-on fa-2x fa-rotate-180 inactive" id="off" ></i> </div> $(document).ready(function(){ $('.middle').click(function(){ $('.inactive').show(); $('.active').hide(); }) .click(function(){ $('.inactive').hide(); $('.active').show(); }); }); i have pen of here: http://codepen.io/lucky500/pen/qdzple one approach use toggle $(document).ready(function(){ $('.middle').click(function() { $('.inactive, .active').toggle(); }); }); http://codepen.io/moogs/pen/zgqpox

javascript - Action always going to Index using submit() -

in view, i'm using function, submitform(action) submit form on button click. 1 of many buttons use function. action parameter indicate controller method use. the function seems generate correct action attribute (the path correct in console), directed index method rather action parameter. the button: <input type="button" value="save only" id="save" onclick="submitform('saveonly')" /> the function: function submitform(action) { var $form = $("#myform"); $form.action = ("/area/mycontroller/" + action); $form.submit(); } you're not accessing 'action' attribute of form itself, jquery selector result, in order code work, need access dom element inside selector $form[0]. recommend stick jquery, you're using it!. below working code jquery selectors. <form id="myform"></form> <input type="button" value="save only...

mysql - ON DUPLICATE update nothing -

i know can use update ignore pass on whether there duplicate key. how use following syntax same? insert table on duplicate key *do nothing* you exact same way. insert ignore table .... that silently skip constraint violations. bulk insert (eg insert ignore table select ... ... ), skip rows violate constraint, continue insert rows can be. useful duplicate removal.

python - Find the index of a list of tuples with nondistinct values in first index of tuple -

i'm trying index of list of 2-tuples in python, 0 index of each tuple 'a' : list_of_tuples = [('a', 1), ('a', 2), ('a', 3)] so use following list comprehension try find out index returned, correct? index_list = [x x, y in enumerate(list_of_tuples) if x[0] == 'a'] which gives following error: typeerror traceback (most recent call last) <ipython-input-22-5d47328b7d9a> in <module>() ----> 1 index_list = [x x, y in enumerate(list_of_tuples) if x[0] == 'a'] typeerror: 'int' object not subscriptable how find out index associated searching list of tuples value in 0th index being equal 'a' ? use value y compare not index x : list_of_tuples = [('a', 1), ('a', 2), ('a', 3)] index_list = [x x, y in enumerate(list_of_tuples) if y[0] == 'a'] now index_list [0, 1, 2] .

android - Where to get info about the themes and xml attributes -

here in code below <style name="customactionbartheme" parent="@style/theme.holo"> <item name="android:actionbarstyle">@style/myactionbar</item> <item name="android:actionbartabtextstyle">@style/myactionbartabtext</item> <item name="android:actionmenutextcolor">@color/actionbar_text</item> </style> where info attribute android:actionmenutextcolor , etc. , how know have use attribute here. check documentation property actionmenutextcolor : color text appears within action menu items. may reference resource, in form "@[+][package:]type:name" or theme attribute in form "?[package:][type:]name". may color value, in form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". here can find examples styling action bar

java - JPanel size is not known on start -

when create board instance square instance, try assign size of window integers x , y. fail because seems on start size 0. in constructor in board.java, x , y shouldn't -50 end now. square.java: package square; import javax.swing.*; public class square extends jframe { public square(){ add(new board()); setsize(800, 800); setvisible(true); } public static void main(string[] args){ new square(); } } board.java package square; import javax.swing.*; import java.awt.*; public class board extends jpanel{ int x,y; public board(){ x = width-50; y = height-50; } public int width = (int) getsize().getwidth(); public int height = (int) getsize().getheight(); public void paintcomponent(graphics g){ super.paintcomponent(g); g.fillrect(x,y, 100, 100); } } full code clarification: square.java package square; import javax.swing.*; public class square extends jframe...

Windows Phone, Prism.StoreApps: How to avoid activation of a certain page after suspension or termination? -

i want ensure in case app navigated page, app on (in case previous) page after suspended or terminated. in case page taking photos. not want user return page after app in background since has no context information. context information on previuos page. how achieve prism.storeapps? background: if app suspended state of app remains after resumed, hence last active page active again. have no real idea how set page active in case. if app terminated prim.storeapps restores navigation state , navigates last active view model (hence last active page). not know either how alter navigation state in case page navigated to. in meantime fond working solution myself. might not best , there might better solutions, works. for resuming app handle resuming event: private void onresuming(object sender, object o) { // check if current root frame contains page not want // activated after resume var rootframe = window.current.content frame; if (rootframe != null &...

c# - Pass a value from textbox to entityframework insert method in windows form -

i using c# windows forms entityframework 6.1.3 datasource.i tryng insert data windows form. have searched various guides of them show example this private void createcash(object sender, devexpress.xtrabars.itemclickeventargs e) { legalgridview.addnewrow(); legalgridview.showpopupeditform(); var cashbookcreate = new cashbook { cashtransact = cashtransacts.name }; dbcontext.cashbooks.add(cashbookcreate); dbcontext.savechanges(); } } cashtransact name of class , in format enters "legal fees" in database want substitute "legal fees" value in textbox 'cashtransacts' unfortunately when replace there cashtransacts.name instead gets me name of column instead of value type in? "value in textbox" the correct way value textbox textbox.text. the textbox.name return name of control provided it.

Ruby on Rails: bad username / password? (535 Auth failed) -

i finished ruby foundations coursework @ bloc , i'm starting bury head rails development. things going smooth until hit snag devise , confirmation emails. tried googling , looking around @ other questions couldn't find gave me pull , apply situation. i'm receiving following error when signing account. net::smtpauthenticationerror in devise::registrationscontroller#create 535 authentication failed: bad username / password error extracted source around line #976 def check_auth_response(res) unless res.success? raise smtpauthenticationerror, res.message end end from other posts know you'll want see have config/initializers/setup_mail.rb file looks this: if rails.env.development? actionmailer::base.delivery_method = :smtp actionmailer::base.smtp_settings = { address: 'smtp.sendgrid.net', port: '587', authentication: :plain, user_name: env['sendgrid_username'], password: ...

rest - How to activate authorization only for some of HTTP methods in Apigility? -

Image
on configuration page {api name} -> {service name} -> authorization single methods service can put under authentication: in page can specify http methods put under authentication, entity , collection service. e.g.: if anderstand correctly, checked methods should require authorization , other ones not. i have 2 services in application: user , address . problem is: wheter activate authorization 1 of them or not, or if authorization deactivated methods of services -- moment, when choose auth type api, every request requires authentication , returns status code 401 , if no credentials sent. what can wrong here? how put methods under authentication? update the relevant configs: /config/autoload/global.php return array( ... 'zf-mvc-auth' => array( 'authentication' => array( 'map' => array( 'addressbookapi\\v1' => 'demo', ), ), ), ); /...