Posts

Showing posts from September, 2015

node.js - How to mock a third-party api calls in the backend -

i'm testing application mocha , supertest, test like var request = require('supertest'), app = require('./bootstrap.js'); describe('...', function() { it('...', function() { request(app) .get('/some/url') // ... }); }); the bootstrap.js real application before listen ports all works perfect have add calls third-party api , testing slow so when do, test example takes 5 seconds request(app) .get('/my/endpoint/that/makes/call/others') // ... how can make fake calls during test real when running application? you can use nock purpose.

java - player naming with loops -

this question has answer here: scanner skipping nextline() after using next(), nextint() or other nextfoo()? 14 answers im having problem loop im doing. when ever run program displays please enter name of player 1? please enter name of player 2? when enter first name automatically prints please enter name of player three. 3 players have been created can name 2 appears advice public static void startgame() { system.out.println("how many players like?"); int noplayers = input.nextint(); (int = 0; < noplayers; i++) { system.out.println("what 1st name of player " + (i + 1) + "?" ); string name = input.nextline(); player player = new player (name, 80); players.add(player); } note 80 money. you should add input.nextline() after int noplayers = input.nextint()

windows - Access denied if Call used along with MOVE in batch script -

here batch script call jekyll build move _site e:\ md temp set src_folder=e:\_site set tar_folder=.\temp /f %%a in ('dir "%src_folder%" /b') move %src_folder%\%%a %tar_folder% pause in script if jekyll build command not used,all move , make directory commands working if call added,the output shown configuration file: e:/workspace/github/rrevanth.github.io/_config.yml source: e:/workspace/github/rrevanth.github.io destination: e:/workspace/github/rrevanth.github.io/_site generating... c:/ruby22-x64/lib/ruby/gems/2.2.0/gems/posix-spawn-0.3.10/lib/posix/spawn.rb:164: warning: cannot close fd before spawn 'which' not recognized internal or external command, operable program or batch file. done. auto-regeneration: disabled. use --watch enable. access denied. subdirectory or file temp exists. here,it showing access denied.is there workaround or doing wrong here. thanks in advance! apparently atte

javascript - How to pass value from a form control via ajax to node.js -

i new jquery/node.js world. so, trying basic stuff getting stuck. checked questions not able hold of right approach. so, here posting code understand wrong here: i using express framework view template engine build using ejs. this script have written in index.ejs <script> $(document).ready(function() { $("button1").click(function() { var obj = $('#text1').val(); $.post("/localhost:3000/",{val: obj}, function(restxt, status, xhr) { if (status=="success") { alert("external content loaded successfully"); //code } if (status=="error") { alert(xhr.status + xhr.statustext); //code } }) }) }); </script> and on index.js render html ejs, have written foll

python - Sending a StringIO to a Twisted FileSender -

i trying send image data filesender in twisted. works fine if use temporary file save image; #works img = image(format='png', blob=base64.decodestring(dt)) img.save(filename='/tmp/tmp.png') file = open('/tmp/tmp.png','rb') filesender = filesender().beginfiletransfer(file, request) def filefinished(ignored): request.finish() filesender.addcallback(filefinished) however do in memory rather file. have tried use stringio this, filesender seems send few bytes before giving up. doing wrong? img = image(format='png', blob=base64.decodestring(dt)) buffer = stringio() img.save(buffer) filesender = filesender().beginfiletransfer(buffer, request) def filefinished(ignored): request.finish() filesender.addcallback(filefinished) your stringio positioned @ eof when try send it. it's surprising sends few bytes (i suspect doesn't , you're seeing http framing). try seeking beginning before call beginfiletransfer . also, do

enums - Possibility of assumption in C# -

can make assumptions on casted int value of system enums in c#? for example: //dayofweek (int)dayofweek.monday == 1, (int)dayofweek.tuesday == 2, (int)dayofweek.wednesday == 3, (int)dayofweek.thursday == 4, (int)dayofweek.friday == 5, (int)dayofweek.saturday == 6, (int)dayofweek.sunday == 0 the logic of code depends on it. however, don't feel writing own mapping, because it... wrong solution. edit here comes culture thing well. iso standard - monday 1st day. in usa - sunday 1st day. yes, can rely on it, insofar documented that: the dayofweek enumeration represents day of week in calendars have 7 days per week. value of constants in enumeration ranges dayofweek.sunday dayofweek.saturday. if cast integer, value ranges 0 (which indicates dayofweek.sunday) 6 (which indicates dayofweek.saturday). of course, while unlikely so, microsoft free change in future releases.

sorting - C++ Most efficient way iterate specific contents in vector -

i have 2 vectors, vec , p, such p vector of pointers different locations in vec. so like: p[0] = &vec[12] p[1] = &vec[20] p[3] = &vec[1] etc. p's size less or equal vec, , contain no duplicate references same location in vec. what i'd have data structure can iterate through dereferenced values of p in order of index pointing in a. above example, result need iterate through in order vec[1], vec[12], vec[20]. i know can position in vec p pointing doing p[i] - &vec[0] , , implement using std::sort , custom comparing function, feel there more efficient way o(nlogn) of sort function. wrong that. thanks help! after discarding few mental ideas, thought of simple one: std::vector<char> is_pointed_to(vec.size(), 0);//initialize "bools" "false" //set is_pointed_to values for(t* pointer : p) { size_t orig_index = pointer - &vec[0]; is_pointed_to[orig_index] = 1; //set index "true" } //now iteration

c++ - Ushing shmat and shmget with forks to multiply a matrix -

this assignment i'm working on class. must use forks, shmget, , shmat create multiplied matrix 2 given matrices. each fork 1 instance of multiplication each (this required). size_t size = matrix1.height * matrix2.width * sizeof(int); int shmid = shmget(2000,size,0); int ** shm; shm = (int ** )shmat (shmid, 0 , 0); (int = 0; < matrix1.height; i++){ (int j = 0; j < matrix2.width; j++){ cout << "i: " << << "j: " << j << endl; shm[i][j] = 0; cout <<"a" << endl; } } (int = 0; < matrix1.height; i++){ (int j = 0; j < matrix2.width; j++){ vector<int> row = matrix1.matrix_rows_by_columns[i]; vector<int> column; (int s = 0; s < matrix2.height; s++){ column.push_back(matrix2.matrix_rows_by_co

sorting - opencl Bitonic sort with 64 bits keys -

i used nvidia sdk bitonic sort , works great me. 32 bits (uint) need ulong keys. have typically 2^14 keys @ time , power of 2. searched on not find kernel designed ulong. i tried modified nvidia sdk bitonic sort using ulong keys not work. kernel not crash after de call clenqueuendrangekernel got error : cl_invalid_command_queue can tell me how modify bitonic sort or radixsort, or can sort ulong keys? i running nvidia quadro 4000 opencl 1.1 cuda 6.5.20 full_profile used original nvidia sdk bitonicsort.cl i used"ulong" keys , value input , ouput instead of "uint" thanks helping i made work-around suit need. used 30 bits of key , 18 high bits of value sorting. changed comparators (2 lines): '#define mask 0xffffc000 // suit need from this: if( (*keya > *keyb) == dir ) this: if(((*keya > *keyb)||((*keya == *keyb)&&((*vala & mask)> (*valb & mask)))) == dir ) it works fine. but, still, it's work-a

python - How do I load data in many-to-many relation using pony orm? -

here entities: class article(db.entity): id = primarykey(int, auto=true) creation_time = required(datetime) last_modification_time = optional(datetime, default=datetime.now) title = required(str) contents = required(str) authors = set('author') class author(db.entity): id = primarykey(int, auto=true) first_name = required(str) last_name = required(str) articles = set(article) and here code i'm using data: return left_join((article, author) article in entities.article author in article.authors).prefetch(entities.author)[:] whether i'm using prefetch method or not, generated sql looks same: select distinct "article"."id", "t-1"."author" "article" "article" left join "article_author" "t-1" on "article"."id" = "t-1"."article" and when iterated on results, pony issuing yet quer

freeRadius using EAP with custom auth script -

i attempting setup freeradius server authenticate against web service. reason there complicated workflow involving account status , mac address. workflow seemed out of place in freeradius. user names, , encrypted passwords stored remotely radius server. works fine using radclient test. when started using the access point, learned communicates radius server via eap-tls. means user-password argument not available script. is there way have eap auth check user authentication against script? mean, can password send secondary service? alternately, there way user-password encrypted eap-message data? access points don't place restrictions on eap type. device connecting ap negotiates eap type freeradius. if it's using eap-tls it's windows machine hasn't been configured different. investigate eap flavours find out ones available. if have eap-ttls-pap can send plaintext password wireless client, , user authenticate against web service. in freeradius v3.

oracle11g - Before update trigger with referential integrity in oracle 11g -

i want understand before update in trigger means. i have table called dept_mst dept_id primary key. has 2 rows dept_id 1 , 2. another table emp has columns emp_id primary key , emp_dept_id foreign key referencing dept_id of dept table. now if add before update trigger on emp tables emp_dept_id column check if new value emp_dept_id present in master table dept if insert new row new dept_id dept table. now if update emp_dept_id 3 emp_dept_id 2 in emp table giving integrity constraint violation error parent not found. so, does mean oracle checks integrity constraints first , calls "before update" trigger? then how can bypass check , call before update trigger? what "before update" mean here? how can achieve above result using triggers , not using explicit pl sql block? thank you non-deferred foreign key constraints evaluated before triggers called, yes. if can declare foreign key constraint deferrable (which require

Understanding Javascript asynchronous setInterval in canvas -

the following code creates canvas ball @ centre when init() method invoked using setinterval . when keydown() event fired ball moves on x , y axis (depending on key user has pressed). struggle understand happens when key pressed. does setinterval stop when key pressed update key value ( keyleft , keyright , etc) , resumes , takes updated values consideration or does code inside key event execute while setinterval in progress? i 've read setinterval asynchronous while key events synchronous , since javascript single threaded second option can't true, right? use knowledge on one.. <canvas id="canvas" style="border: 1px solid black" width="400" height="400"></canvas> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> var ball = { positionx: 200, positiony: 200, keyleft: f

xml - How can i use XSL sheet to filter C# Application -

Image
i apologize if not explaining right. i need create c# application when value selected combobox, supposed filter out , transform xslt sheet. have 3 different criteria in combobox makes challenging. i'm stuck on right designing xlst, since criteria different. here xslt sheet far, displays information. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" > <xsl:variable name="features" select="programming/features/feature" /> <xsl:template match="/" > <html> <head> <title>programming</title> </head> <body> <table border="1"> <tr> <th >programming</th> <th >intended use</th> <xsl:for-each select="$features"> <th><xsl:value-of select="."/><

angularjs - Updating a controller's scope using a directive's method -

how can use method in directive update variable in controller's scope? i using: dropzone.js , angular-dropzone.js . one of dropzone's methods .getqueuedfiles() . use method update variable in controller scope, isn't working. able update controller scope can show , hide things , pass number of files next step in form. here angular: .controller('imagesctrl', function($scope) { $scope.queuedfiles = 0; $scope.dropzoneconfig = { init: function() { this.on("addedfile", function(file) { $scope.queuedfiles = $scope.dropzone.getqueuedfiles().length; }); } }; }) and here html: <form class="dropzone clear" method="post" enctype="multipart/form-data" ng-dropzone dropzone="dropzone" dropzone-config="dropzoneconfig"> </form> <div>queued files: {{queuedfiles}}</div> this correct code var app = angular.module('

angularjs - After text input model set, angular search filter breaks -

i'm writing combobox directive, , having trouble it. setup when clicks input, shows options in dropdown, , type, filters results. if click on result, should populate input value. unfortunately, seem have done wrong, when click on result, populates field, if erase values of field, rather returning original search, parses through result selected. shows values typing searches through values match search text , clicked value. how directive called: <combobox data="combobox.systems" results="systemsearch" placeholder="system"></combobox> directive html: <div class="combobox" ng-click="$event.stoppropagation()"> <input type="text" ng-model="search.value" search-id="search.id" ng-class="{ resultsopen: showdropdown }" ng-change="revealdropdown()" ng-focus="revealdropdown()" ng-blur="hidedropdown()"> <a class="dropdown&

sql - Adding more joins to a select -

i having trouble trying add 2 more joins select. bellow works me: from table1 inner join table2 b on a.id = b.id left join table3 c on a.requested_by = c.user_name left join table3 d on a.coordinator = d.user_name inner join table4 e on a.id = e.parent_id inner join table5 f on e.id = f.id but need more information, tried (added last 2 rows): from table1 inner join table2 b on a.id = b.id left join table3 c on a.requested_by = c.user_name left join table3 d on a.coordinator = d.user_name inner join table4 e on a.id = e.parent_id inner join table5 f on e.id = f.id inner join table6 g on a.id = b.id left join table3 h on g.coordinator = h.user_name and isn't working should. question: how can add last 2 joins make select works? thanks. you're not joining table6 (g) anywhere. think join: inner join table6 g on a.id = b.id should instead: inner join table6 g on a.id = g.id and side note, hope you're using table aliases more meaningful a, b,

c++ - loading ogl texture using DEVIL -

here code typedef struct texture { glubyte *data; gluint bpp; gluint width, height; gluint id; }texture; class textureloader { public: textureloader() { ilinit(); iluinit(); } void load(ilenum filetype, const char *filename, texture *texture) { ilload(filetype, filename); texture->width = ilgetinteger(il_image_width); texture->height = ilgetinteger(il_image_height); texture->bpp = ilgetinteger(il_image_bytes_per_pixel); texture->data = ilgetdata(); ilenable(il_conv_pal); unsigned int type = ilgetinteger(il_image_format); glgentextures(1, &texture->id); glbindtexture(gl_texture_2d,texture->id); glubuild2dmipmaps(gl_texture_2d, texture->bpp, texture->width, texture->height, type, gl_unsigned_byte, texture->data); gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear_mipmap_nearest);

Non Unique Username with ASP.Net Identity 2.0 -

i have situation username not unique. email used username , 1 email can have many different passwords in database , legitimate. how use asp.net identity 2.0 in situation. var result = await signinmanager.passwordsigninasync(model.username, model.password, model.rememberme, shouldlockout: false); above line expects 1 user in database. if multiple records returned - returns failure. expected logic doesn't work me. how override logic? alternatively, ready customize login problem - not sure things done part of passwordsigninasync. adding cookies etc. please help. i made work. had use username + password combination unique username. these different situations in industry different types of needs.

c++ - If a function is only called from one place, is it always better to inline it? -

this question has answer here: when use inline function , when not use it? 13 answers if function used in 1 place , profiling shows it's not being inlined, there performance advantage in forcing compiler inline it? obviously "profile , see" (and in case of function in question, did prove small perf boost). i'm asking out of curiosity -- there performance disadvantages reasonably smart compiler? no, there notable exceptions. take code example: void do_something_often(void) { x++; if (x == 100000000) { do_a_lot_of_work(); } } let's do_something_often() called , many places. do_a_lot_of_work() called (one out of every 1 hundred million calls). inlining do_a_lot_of_work() do_something_often() doesn't gain anything. since do_something_often() nothing, better if got inlined functions call it, , in rare c

ios - How can I select a picture from the camera roll, then save it to the "Supporting Files" folder of my app, then pick up the name of the saved file? -

i'm building ios game in objective-c, , part of ability unlock new "ships". now, have few, want "custom ship" option, user selects image camera roll, , displays ship in-game. so, know how select picture (don't need camera), save supporting files folder in app game can call up. need find out name of file game can call correct image. any appreciated. i have tried -(ibaction)choosefromlibrary:(id)sender { uiimagepickercontroller *imagepickercontroller= [[uiimagepickercontroller alloc]init]; [imagepickercontroller setsourcetype:uiimagepickercontrollersourcetypephotolibrary]; // image picker needs delegate can respond messages [imagepickercontroller setdelegate:self]; // place image picker on screen [self presentviewcontroller:imagepickercontroller animated:yes completion:nil]; } //delegate method called after picking photo either camera or library - (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdi

How to use argument-resolvers using annotation in Spring boot? -

i use argument-resolvers in spring boot. how go it? done in xml below. <mvc:annotation-driven> <mvc:argument-resolvers> <bean class="nl.t42.spring31.validatingrequestbodymethodargumentresolver"/> </mvc:argument-resolvers> </mvc:annotation-driven> see here you can do: @configuration @enablewebmvc public class webconfig extends webmvcconfigureradapter { @override public void addargumentresolvers(list<handlermethodargumentresolver> argumentresolvers) { // equivalent <mvc:argument-resolvers> } @override public void configuremessageconverters(list<httpmessageconverter<?>> converters) { // equivalent <mvc:message-converters> } } @enablewebmvc override boot defaults, may want skip it.

ios - Forcing failure of a Kiwi test -

is there way force failure in kiwi test, i.e. equivalent of xctfail(). i can write like [@"" should] benil] that fail figuring kiwi must have little more expressive of developer's intent baked framework. yep, can use fail() macro: fail(@"message");

bash - handling hanging shell command in ruby -

i have cronjob runs ruby scrip collects data bash utility (ipmitool). utility hangs, causing whole script hang, causing cron jobs stack up... the line of code is: 'macaddress' => `timeout 5 ipmitool lan print | grep 'mac address'`.split(':',2)[1].strip in cron job still causes script hang when manually test following in ruby script & run form terminal: ans = `timeout 1 sleep 20 | grep 'hello'` the shell command terminates how can prevent cron script hanging? edit: here's strace of hanging (hang @ select) : open("/root/.freeipmi/sdr-cache/sdr-cache-xxxx.localhost", o_rdonly) = 4 mmap(null, 2917, prot_read, map_private, 4, 0) = 0x7f0ea2dfd000 ioctl(3, ipmictl_send_command, 0x7fff74802020) = 0 select(4, [3], null, null, {60, 0}

node.js - Converting an image to rows of grayscale pixel values -

i'd use node indico api . need convert image grayscale , arrays containing arrays/rows of pixel values. start? these tools take specific format images, list of lists, each sub-list containing 'row' of values corresponding n pixels in image. e.g. [[float, float, float ... *n ], [float, float, float ... *n ], ... *n] since pixels tend represented rgba values, can use following formula convert grayscale. y = (0.2126 * r + 0.7152 * g + 0.0722 * b) * we're working on automatically scaling images, moment it's provide square image it looks node 's image manipulation tools sadly little lacking, there solution. get-pixels allows reading in images either url or local path , convert ndarray should work excellently api. the api accept rgb images in format get-pixels produces them, if you're still interested in converting images grayscale, can helpful other applications it's little strange . in standard rgb image th

php - I have trouble with my SESSION that change when i insert somethnig with POST -

i have trouble code below, put $level in $_session , don't know how that. $level replace user $_session['level'] , logged out. <?php session_start(); if( $_post['action'] == 'add' ) { $level = $_post['level']; ?> <form action="<?php $_server[php_self]; ?>" method="post" > <input type="text" name="level" value="" placeholder="level" /><br /> <input type="hidden" name="action" value="add" /> <input type="submit" value="add user" /> </form> i'd common issue session variable forgetting session_start() in top of document. have put session_start() belongs, but have forgotten define session variable :) this how it's done. $_session['level'] = $_post['level'];

How to start Selenium RemoteWebDriver or WebDriver without clearing cookies or cache? -

use case: login username, navigated 2nd factor authentication page 1 of number of things (i.e. answer knowledge based question), , navigated final page enter password. close browser , attempt login again username. time 2nd factor authentication page bypassed because app recognizes cookies , user prompted enter password directly. problem: using selenium remotewebdriver run these tests on separate test machine , when close first browser , open new instance of remotewebdriver appears starts clearing cookies , cache , 2nd factor authentication page comes every time attempt login. what need: figure out how create new instance of remotewebdriver without automatically clearing cookies or cache, 2nd factor authentication page bypassed. need ie, chrome, firefox , safari. i don’t have code clears explicitly, don’t have attempts force not clear (if that’s in existence.) haven’t tried of else because have no idea try. versions: selenium webdriver: 2.45.0.0, selenium grid: 2.45

Is there a NOT operator in calabash query syntax? -

the title pretty covers question. how can (for instance) obtain textview elements ids not contain "some_prefix"? can obtain textview elements , iterate on them, kicking out ones don't (and will), i'd rather have clear query me. it's inefficient, can do: query("android.widget.textview") - query("android.widget.textview {id contains[c] 'some_prefix'}") the first query gets set of textviews, excludes contain 'some_prefix' returned in second query .

rust - How to enter command line argument with docops? -

how can enter command line arguments in rust using docopts? i'd able enter u8 in vector , parse docopts. you can use std::env::args method obtain iterator. then, can use .collect on iterator vector of string s. use std::env; fn main () { let args: vec<string> = env::args().collect(); println!("{:?}", args); } example output: simon@simon-desktop:~$ rustc t.rs simon@simon-desktop:~$ ./t abc def ["./t", "abc", "def"]

arduino - Is it possible (and does it make sense) to have a bluetooth iOT device in peripheral mode listening to both, BLE and Bluetooth Classic connections -

we building device needs compatible newer smartphones run ble backwards compatible bluetooth 2.1. we using mediatek linkit 1 board our prototype can operate in dual mode. have bluetooth classes available, seems have pick between either running 1) bluetooth classic 2.1 or 2) ble the classes , docs here: http://labs.mediatek.com/site/znch/developer_tools/mediatek_linkit/api_references/lib_bluetooth.gsp we want make our device compatible many smart phones possible wonder whether possible have device peripheral listen both, ble , bluetooth classic connections @ same time. if gets connected via either, stop broadcasting other? the technical way seems have maybe dip switch on iot device sets mode , uses ble code base or classic code base based on position of dip switch. not seem elegant me. lastly, wonder if question makes sense. searched around hours , cannot seem find else doing this, wonder if people going ble these days , don't care about classic br/edr anymore. apprec

excel - How to delay a formula to be shown for a certain number of hours? -

i'm using excel 2013. in cell d5 have date of birth, in cell e5 have formula recognizes if today birthday , if is, shows yes , if not no . formula works great formula must not show yes before 10 a.m.! how can delay formula shows yes if it's past 10am? i'm not doing in vba because i've got task write formula! here's formula: =if(text(d5;"d.m.")=text(today();"d.m.");"yes";"no") please can write me delayed formula or tell me function should use delay formula? presumably want show "yes" 10:00 until midnight on day? you possibly use hour function in conjunction current formula, e.g. =if(and(text(d5;"d.m.")=text(today();"d.m.");hour(now())>=10);"yes";"no") or perhaps simpler use datedif current date comparison this: =if(and(datedif(d5;today();"yd")=0;hour(now())>=10);"yes";"no")

Google Apps Script HtmlService template and URLs -

i giving first shot @ html templating google appsscript , have had pretty decent experience far. problem urls not being processed (replaced "false") my code.gs looks : var section = htmlservice .createtemplatefromfile('section') .evaluate() .setsandboxmode(htmlservice.sandboxmode.iframe); logger.log(section.getcontent()); and html (section.html) : <? var section = [ {title: "foo", paragraph: "bar", url: "https://www.youtube.com/v=foobar"}, {title: "foo2", paragraph: "bar2", url: "https://www.youtube.com/v=foobar2"}]; (var x in section) { ?> <h1><?= section[x].title ?> </h1> <p><?= section[x].paragraph ?> </p> <a href="<?= section[x].url ?>"> link </a> <? } ?> and result of (the log) : <h1>foo </h1> <p>bar</p> <a href="false"> link </a> <h1>

file storage - Windows Azure Multi-region VMs and SQL Server -

i moving website windows azure. majority of users india , usa. website uses sql server database , file system users can upload images , view them. i'm thinking creating 2 vms 1 in west , 1 in southeast asia , use traffic manager load balance between web servers, don't know how set database , file share. can me? traffic manager can connect vms on region on public endpoint. in case, have create 2 public endpoints, 1 each vm. then, can put traffic manager in front of these 2 public endpoints. similarly, vms can connect sql on own public endpoint.

How do I make a JTextPane have a different tab size in Java? -

i have jtextpane, have noticed if use .settext() tabs removed. fix see 2 options: make tabs set properly. replace tabs html special character &#8195; , change tab size in jtextpane match width of html tab. i not know how #1 trying use crude hack #2. question is, how change tab size jtextpane using htmldocument, or how settext() , not have tabs removed? also using gettext() , settext() in order save text inside jtextpane. thank in advance. in order solve problem without method 1 or 2 have done this: textpane.getinputmap().put(keystroke.getkeystroke("tab"), "tab"); textpane.getactionmap().put("tab", new abstractaction("tab"){ private static final long serialversionuid = -2621537943352838927l; public void actionperformed(actionevent e){ try { textpane.getdocument().insertstring(textpane.getcaretposition(), " ", null);//the " " html special character (tab) in plain t

java - How to get a tag which is inside another one xml android -

this xml code, want items xml code. the problem don't know how directly 'item' because u see 'item' 'channel': http://www.scarlett-fan.com/feed/ and part of java code // initial eventtype int eventtype = xpp.geteventtype(); // loop through pull events until reach end_document while (eventtype != xmlpullparser.end_document) { // current tag string tagname = xpp.getname(); // react different event types appropriately switch (eventtype) { case xmlpullparser.start_tag: if (tagname.equalsignorecase(key_site)) { // if starting new <site> block need //a new stacksite object represent curstacksite = new stacksite(); } break; case xmlpullparser.text: //grab current text can use in end_tag event curtext = xpp.gettext(); break; case xmlpullparser.end_tag:

escaping - Suppress periods from ending brief description in JAVADOC_AUTOBRIEF -

the javadoc_autobrief setting seems nice convenience, instead of writing: /// \brief brief description. /// brief description continued. /// /// detailed description starts here. you can write: /// brief description; brief description continued. /// /// detailed description starts here. yet have used ; here merge content single sentence, have option of somehow preventing period ending brief description. when went poke through source little, found suggestion around precise problem escaping period. however: /// brief description\. brief description continued. did not work me. based on suggestion, appeared work instead "escaping space" /// brief description.\ brief description continued . i'm not convinced that's actual "feature" of doxygen, , confused , ignored error state. can confirm me documentation incorrect \. space being used purpose? (if so, involved doxygen followed tag here want file report that?) if \ (backslash-

scala - Adding data files to SBT project -

i add data file or configuration file along application (such sample.conf). file should available user he/she can edit sample configuration further customize application. how can add such files project such that this file becomes part of distributable, , how can link in source documentation, purpose can doucmented, and this file goes special directory (such conf) or there such predefined task available. sbt native packager provides support doing want, though you'll have dig through docs bit. universal packager best approach you. http://www.scala-sbt.org/sbt-native-packager/

Debugging Chrome extension default_popup using dev tools -

Image
i'm trying simple debugging on chrome extension. when try catch event id , show in alert, chrome closes alert , default popup window making impossible tell in alert. instance: $("a[data-toggle='pill']").on('shown.bs.tab', function (e) { alert(e.target.id); }); to instead log console, do: $("a[data-toggle='pill']").on('shown.bs.tab', function (e) { console.log(e.target.id); }); however, if inadvertently close popup or have reload extension, console window opened using "inspect popup" on popup closed. makes tedious debug process. what better approach debugging , test chrome extensions default_popup? you can debug chrome extensions go link chrome://inspect/#extensions you can see installed extensions , can inspect them :) grab link extension , change url popup window url in ex: changed background.html --> popup.html

increment - MySQL: Strange WHERE behaviour with incrementing variables -

i have table 16 sequential rows: create table t ( id int not null primary key auto_increment ); insert t values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); executing following statement, expected, returns rows: mysql> select * t cross join (select @x:=0) id=(@x:=@x+1); +----+-------+ | id | @x:=0 | +----+-------+ | 1 | 0 | | 2 | 0 | | 3 | 0 | ... however, following statement, rather returning every other row, returns nothing : mysql> select * t cross join (select @x:=0) id=(@x:=@x+2); empty set (0.00 sec) what explain this? sql fiddle i'm not sure why confused. code doing specifying. during first iteration -- assuming t read in order (which not guaranteed) -- have: id = 1, @x = 2 then: id = 2, @x = 4 id = 3, @x = 6 and on. these values never equal, no rows returned. if want every other row, use mod() : where mod(id, 2) = 1 variables not needed.

search - Results extraction for a dynamic result using selenium webdriver -

i working on application, need provide search criteria available in database , no. of results displayed not equal every time. for ex: search 1234 , may display 4 results today , 3 results next day, requirements below: how provide search criteria dynamically under search(bdd). how display results in console given input. and want display results , validate clicking on each , every result. note: app developed using angular js. have tried using webelement list not extracting dynamic search result drop down looking in page. also can suggest how provide search result under behavioral driven development. please suggest using selenium commands. thanks support , co-operations.

javascript - Printing a div form with data to a page -

i have div (divcontents) containing form has several questions , input textboxes users enter answers. have button show , hide answers each input textboxes (the textboxes change colors when click button reveal/hide answers). i've created print module me print div form: function printcontent(){ var divno = document.getelementbyid("divpageno").value; var divcontents = document.getelementbyid(divno).innerhtml; var frame1 = document.createelement('iframe'); frame1.name = "frame1"; frame1.style.position = "absolute"; frame1.style.top = "-1000000px"; document.body.appendchild(frame1); var framedoc = frame1.contentwindow ? frame1.contentwindow : frame1.contentdocument.document ? frame1.contentdocument.document : frame1.contentdocument; framedoc.document.open(); framedoc.document.write('<html><head>

opencv - why it's so slow in data exchanging between CPU and GPU memory? -

it's first time using opencl on arm(cpu:qualcomm snapdragon msm8930, gpu:adreno(tm)305). i find using opencl effective, data exchanging between cpu , gpu takes time, as can't imaging. here example: cv::mat mat(640,480,cv_8uc3,cv::scalar(0,0,0)); cv::ocl::oclmat mat_ocl; //cpu->gpu mat_ocl.upload(mat); //gpu->cpu mat = (cv::mat)mat_ocl; just small image this, upload option takes 10ms, , download option takes 20ms! takes long. can tell me situation normal? or goes wrong here? thank in advance! added: my messuring method clock_t start,end; start=clock(); mat_ocl.upload(mat); end = clock(); __android_log_print(android_log_info,"tag","upload time = %f s",(double)(end-start)/clocks_per_sec); actually, i'm not using opencl exactly, ocl module in opencv(although says equal). when reading opencv documents, find it's tell transform cv::mat cv::ocl::oclmat (which data uploading cpu gpu)to gpu calculation, haven't found memory

java - why does system.out.write convert int value to char? -

suppose int b = 99 . why system.out.write(b) print "c" instead of 99? @ same time using printwriter actual value of b (99) if b = 'c'? the thing system.out.write(int) consider argument byte , write stream. in case since passed 99 u0063 , hence c printed.

java - Is Thread.sleep(n) blocking other things from going? Something better to replace it? -

i have little application counting time pressing button, use thread.sleep() count. when button pressed, triggers actionlistener class perform thread.run() . thread.sleep() started inside run() function. //the thread class twentymins implements runnable @override public void run() { try { thread.sleep(1000*60*20); } catch (interruptedexception e1) { e1.printstacktrace(); } } } //the actionlistener class reset implements actionlistener { public static twentymins count = new twentymins(); @override public void actionperformed(actionevent event) { count.run(); } } the issue is, button not bounce , able pressed again. , application can't stopped pressing exit button on jframe. straightforwardly, think application frozen while thread.sleep() running. is there better thread.sleep()? you didn't start background thread here. object can implement runnable (and run method)

Make MVC URL same as old ASP.Net website -

i have website developed in dot net 2.0 need update in mvc framework. how keep old urls same in mvc? eg. www.something.com/home.aspx , www.something.com/about.aspx . need keep url structure. please help. use mvc routing make urls same old site. public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "home", url: "home.aspx", defaults: new { controller = "home", action = "index" } ); routes.maproute( name: "about", url: "about.aspx", defaults: new { controller = "home", action = "about" } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } note in mvc 5 use

c - Can hardlinks be overwritten without using a temporary file? -

i have hardlink must exist on filesystem. inode hardlink points not constant. want update hardlink without adding temporary entry directory. (creating file without directory entry can done using open(2) temp flag.) the issue i'm facing replacing/updating hardlink. documentation on relevant system calls, seems have 2 options, , neither avoids temporary file: using renameat , possible insure hardlink exists. however, must consume hardlink , hence necessitating temporary files (not mention inability dereference symbolic links). using linkat , possible produce hardlink without sacrificing file. cannot overwrite existing files; requiring deletion of original hard link. is @ possible create link inode replaces older link same name? you need have file switch link. rename , renameat not need inode linked in same directory; require inode exist on same filesystem, or more on same mount point ; otherwise linux rename fails exdev : exdev oldpath , newpath

javascript - Remove Lines Containing using jquery -

i want create remove lines containing using jquery, here code: <body> search lines for: <input type="text" id="search-lines" value="sometimes|relevance|understand" style="width:100%; margin-top:10px;" /> <button id="process">process!</button> <textarea id="input" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off">sometimes understand word's meaning need more definition. @ dictionary try give of tools need understand word means. seeing word in sentence can provide more context , relevance.</textarea> <textarea id="containing-output" rows="4" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off"></textarea> <textarea id="not-contating-output" rows="4" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off"&g