Posts

Showing posts from July, 2011

Sip/Voip Call Support for all device in android -

i build application sip/voip call. supportable samsung , htc , motorola device. sip call not supportable micromax, xolo etc etc device.so want build app supportable sip call devices.how can do? actually samsung devices doesn't support sip/voip(like s3) there library can use refer building own sip/voip client. i used build voip client using csipsimple, works fine on devices tested. csipsimple imsdroid sipdroid http://code.google.com/p/csipsimple/ https://code.google.com/p/imsdroid/ https://code.google.com/p/sipdroid/

reactjs - How to reuse React component that has different markup? -

i have following component today, represents container box has heading , different rows. how looks: var box = react.createclass({ render: function() { return ( <boxheading title={this.props.headingtitle}/> <boxbody rows={this.props.rows} /> ) } }); var boxbody = react.createclass({ render: function() { return ( {this.rows()} ) } rows: function() { return _.map(this.props.rows, function(row) { return ( <houserow /> ); }, this); } }); now question is: if want reuse box & boxbody instead of using want use kind of row, how it? would pass kind of component want row box? so, <box rowtype={<houserow} /> or similar? the approach chose looks — you can combine box every type of row want, provided has correct interface. called object composition , legit , respected pattern in software engineering. the thing is, in react should not passing rendered component, compone

sql - Combine two queries in PostgreSQL -

i need union in single array of 2 queries : in query related absences achievement of students in quarter : $ssqlasistencia = " select ca.idcadete, coalesce(sum(i.cantidad),0) cantidad cadetes ca, cursos c, cursos_cadetes cc left join inasistencias on i.fk_idcurso = cc.fk_idcurso , i.fk_idcadete = cc.fk_idcadete c.habilitado = true , ca.habilitado = true , c.fk_idanolectivo = ".$aanolectivobuscar." , c.fk_idano = ".$aanobuscar." , c.fk_iddivision = ".$adivisionbuscar." , cc.fk_idcurso = c.idcurso , cc.fk_idcadete = ca.idcadete , (extract(month i.fecha) in ".$trimestre ." or i.cantidad null) group ca.idcadete ";

javascript - declare multiple variables into a variable angularjs -

how put multiple variables 1 variable can minify code usage. how declare can use $scope.bundle instead of these 3 variables : $scope.acc.city, $scope.acc.state , $scope.acc.country. global variable carry multiple variables can use everywhere without need write variables again , again. the way want : $scope.bundle = [{$scope.acc.city, $scope.acc.state, $scope.acc.country}]; $scope.postcode = resp.content; if ($scope.postcode.length > 0) { $scope.bundle = $scope.postcode[0]; $scope.acc = $scope.bundle; } else { $scope.bundle = ''; $scope.acc = $scope.bundle; } instead of : if ($scope.postcode.length > 0) { var data = $scope.postcode[0]; $scope.acc.city = data.city; $scope.acc.state = data.state; $scope.acc.country = data.country; } else { $scope.acc.city = ''; $scope.acc.state = ''; $scope.acc.country = ''; } you're creating array of objects , need provide keys values $scope.bundle = [

javascript - $myform.textinput.$isvalid is true when it should not -

the whole form should not valid until stuff[] has @ least 1 item added it. when user enters in value text box , clicks add adds value stuff[], @ point when value has been added stuff[] should submit button enabled. however, user types text box without clicking add, , nothing in stuff[], makes form valid , enables submit button. <form ng-app="myapp" ng-controller="myctrl" name="myform" ng-submit="submit()" novalidate> <div ng-repeat="things in stuff"> <table><tr><td>{{things}}</td></tr></table> </div> <input type="text" name="app" ng-model="input" ng-required="!stuff[0]" /> <button ng-disabled="!input" ng-click="add()"> <span> add</span> </button> <input type="submit" value="submit" ng-disabled="myform.$invalid" /&g

javascript - How to show html result form a texterea -

in page of web, have textarea write html code. how show html result of textarea other view under texterea. you looking wysiwyg angular: angular wysiwyg directive textangular angular-redactor angular-froala list provided here well: http://ngmodules.org/tags/wysiwyg

Mos score calculation of opus codec with E-Model algorithm -

now want use e-model algorithm calculate opus mos score, need feed parameters e-model, e.g. bpl, ie, can't find value of these params opus in web, can help? or know other used algorithm opus mos? itu-t e-model tutorial. @ table 2 there default values each parameters , recommended range.

php imagick paint all non transparent pixels one color -

i need convert non transparent pixels 1 color (e.g. black). i can use methods exposed php imagick extension http://php.net/manual/en/class.imagick.php as exec() blocked on server. what quickest route achieve this? in end created black pseudo image , copied opacity original image new pseudo image

c# - Working with a .dl_ file in visual studio -

i've sent on .dl_ file need reference within visual studio project, have been told .dl_ file contains 1 interface, 1 model , 1 xml file. i've never worked .dl_ before i'm confused on how go getting such information mentioned above in solution, have googled information not how reference / use it. i have tried right clicking on references > add reference > browse .dl_ location , tried adding error "could not added. please mark sure file accessible, , valid assembly or com component" a dl_ file sounds file compressed. microsoft compresses lot of system files on installation media. decompress it, use expand , microsoft command line utility. expand file, open command window , type this: c:\> cd\ c:\> cd mydirectory c:\mydirectory> expand myfile.dl_ myfile.dll replace mydirectory whatever directory dl_ file in. create dll file, use normal dll. another possibility friend renamed file .dll .dl_ . lot of email clients not allow sen

php - How to Manipulate JQuery .get() response -

using suggestion found @ http://richardmiller.co.uk/2011/03/04/jquery-manipulating-ajax-response-before-inserting-into-the-dom/ able manipulate data response jquery .get() method, i'm unable make changes object. javascript $.get( "returnajax", function( data ) { var $data = $(data); $data.find('#testdiv').append('<p>some text</p>'); console.log($data); }); php public function returnajax() { return "<div id='testdiv'></div>"; } the output in console <div id="testdiv"></div> this seems simple thing i'm not doing right... see .find() get descendants of each element in current set of matched elements, filtered selector, jquery object, or element. which traverses $data descendants #testdiv , $data appear #testdiv element ? try $data.append('<p>some text</p>');console.log($data.is("#testdiv"))

Inserting millions of records into MySQL database using Python -

i have txt file 100 million records (numbers). reading file in python , inserting mysql database using simple insert statement python. taking long , looks script wouldn't ever finish. optimal way carry out process ? script using less 1% of memory , 10 15% of cpu. any suggestions handle such large data , insert efficiently database, appreciated. thanks. sticking python, may want try creating list of tuples input , using execute many statement python mysql connector. if file big, can use generator chunk more digestible. http://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-executemany.html

hide minitests results window in rubymine -

Image
the minitests results window in rubymine driving me crazy. results @ bottom don't want huge window blocking upper right portion of screen. i cannot figure out how disable notification window. i realize not auto-run tests have them run in background without constant notification. attaching picture demonstrate window talking about i using rubymine version 7.1.2 on ubuntu i have tried disabling notification seems not have effect you can disable system notifications in rubymine going appearance & behavior > notifications in preferences , unchecking "enable system notifications" box. there no more granular preference aware of still preserves in-app balloon notifications well.

java - Sticky Collisions -

i'm making quick tilemap game, tilemap collisions. problem when run wall sticks. can out of it, i'm aiming make when hit wall, still fall, instead of stay on wall. i've tried detect collisions separately, doesn't work. here's collision section of code: //31 amount of blocked tiles. for(int counter = 0; counter < 31; counter++) { if(spritex + 40 + velx >= collisionx[counter] && collisionx[counter] + 100 >= spritex + velx &&spritey + 40 + vely >= collisiony[counter] && collisiony[counter] + 100 >= spritey + vely) { velx = 0; vely = 0; collisions = counter; } else { if(counter == collisions && jumping == false) { fall(); } } i know array bulky, i'm fixing that. here's whole class: package main; import java.awt.color; import java.awt.dimension; import java.awt.graphics; import java.awt.graphics2

java - NullPointerException onCreate - android spinner -

i'm having trouble spinner on application. the spinner supposed pass selected item sqlite db , save data. but far everytime press register button throws javanullpointerexception error. this class: public class registermember extends activity implements onitemselectedlistener{ dbadapter dbadapter; edittext txtname; edittext txtpassword; edittext txtpasswordconf; edittext txtemail; edittext txtemailconf; edittext txtschool; button btnjoin; //button btnregister; private string[] state= {"usb","stanford","harvard","ucv","usm","tor vergata", "la sapienza"}; spinner spinner_school; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_members_register); system.out.println(state.length); spinner_school = (spinner) findviewbyid(r.id.spinner_school); arrayadapter<string> adapter_state = new arrayadapter<s

java - Binary search condition -

i'm confused condition of binary search algorithm , costs me lot of time in programming contests. question when use each of these conditions? 1. while (low < high) 2. while (high - low > 1) 3. while (low <= high) low = lowest value in set of solutions. high = largest value in set of solutions. while (low < high) used when you're searching range [low, high) . when updating high , use high = mid . when updating low , use low = mid + 1 . while (high - low > 1) used when you're searching range (low, high) . when updating high , use high = mid . when updating low , use low = mid . while (low <= high) used when you're searching range [low, high] . when updating high , use high = mid - 1 . when updating low , use low = mid + 1 . code below: public class binarysearch { public static void main(string[] args) { integer[] nums = { 4, 9, 12, 18, 20, 26, 28, 29, 55 }; (int = 0; < nums.length; ++i) {

iOS ,Google Map Error: Your key may be invalid for your bundle ID -

clientparametersrequest failed, 3 attempts remaining (0 vs 6). error domain=com.google.httpstatus code=400 "the operation couldn’t completed. (com.google.httpstatus error 400.)" userinfo=0x7f95f4811190 {data=<cfdata 0x7f95f24df240 [0x1030a2eb0]> {length = 145, capacity = 256,bytes = 0x3c48544d4c3e0a3c484541443e0a3c54... 3c2f48544d4c3e0a}} i need error. you need provide api key application. can follow steps in this documentation create api_key google developer console . (note: sample api_key in documentation page throw error, dont use it, create own one) after api key developer console, can paste in appdelegate file. if developing objective-c app, this: [gmsservices provideapikey:@"your_api_key"]; if developing swift app, this: gmsservices.provideapikey("your_api_key"); (replace your_api_key actual key).

javascript - Highcharts custom export hidding on Reset -

i facing 1 issue highcharts. i have code renders custom download instead of highcharts default print , download : $('#container').highcharts({ exporting: { buttons: { contextbutton: { enabled: false }, exportbutton: { text: 'download', y:30, //x: 1, //y: 5, // use download related menu items default context button menuitems: highcharts.getoptions().exporting.buttons.contextbutton.menuitems.splice(2) }, printbutton: { text: 'print', y: 30,

javascript - How to call this function automatically -

im using following function call ajax request, , fill corresponding divs response: $( function() { $(document).ready(function() { var postdata = ""; $.ajax( { url : \'functions/ajax_api.php?\', type : \'post\', data : postdata, success : function( resp ) { $(\'#id1\').html($(\'#id1\' , resp).html()); $(\'#id2\').html($(\'#id2\' , resp).html()); } }); return false; }); }); the function works fine. question how can call automatically every few seconds? i tried using window.settimeout(function, 3000) couldnt set correctly. use setinterval(); instead of .settimeout() let me little bit that var interval , setitinterval; // variables can change names interval = function(){ // ajax code here } to run .. use: setitinterval = setinterval(interval , 30

java - connecting to a database through JDBC -

this question has answer here: connect java mysql database 11 answers i trying follow tutorial in book on connecting program database jdbc. confused on first block of code doing in class. whan run code error saying java.sql.sqlexception: no suitable driver found jdbc:mysql://localhost:8889/book_store and code throwing exception in first block inside class. need add sort of dependency or library project? as can tell first attempt @ using db... package com.apress.books.dao; import com.apress.books.model.author; import com.apress.books.model.book; import com.apress.books.model.category; import java.sql.*; import java.util.arraylist; import java.util.list; public class bookdaoimpl implements bookdao { static { try { class.forname("com.mysql.jdbc.driver"); } catch (classnotfoundexception ex) { } } private connection getconnection(

ios - Subviews of custom UIView are equal to nil even after view is loaded -

i'm trying render custom view. problem after view loaded, subviews still equals nil.. not showing , impossible configure. custom view setup through interface builder , outlets linked properties can see below. here custom uiview code : import uikit class badgeview : uiview { @iboutlet weak var progresscircleview: circleprogressview! @iboutlet weak var progressionvalue: uilabel! @iboutlet weak var name: uilabel! override init(frame: cgrect) { super.init(frame: frame) } required init(coder adecoder: nscoder) { super.init(coder: adecoder) } } tell me if need more informations. how initialise badgeview . if using storyboard or xib, view should initialised this: let nib = nsbundle.mainbundle().loadnibnamed("badgeview", owner: self, options: nil) let badgeview = nib[0] as! badgeview

c# - UDPClient stream is slightly delayed. Can I speed it up? -

so have 2 c# applications running on same machine. communicate via udpclient (one application opens streams , sets this: udp1server.client.setsocketoption(socketoptionlevel.socket, socketoptionname.reuseaddress, true); the other application can connect , communicate messages @ acceptable rate, issue there slight delay of maybe half second before recieved on other app. seeing these communicating messages on same machine there should no lag right? the funny messages being send smartphone via bluetooth app 1, via udp app 2. , bluetooth stream faster communication between 2 apps on same machine?! this application sends data: static void unitythread() { try { while (true) { if (bluetoothclients[0].connected) { byte[] sendbuf = encoding.ascii.getbytes(latestdata[0]); udp1server.send(sendbuf, sendbuf.length); } thread.sleep(1);

x86 - Wrong answer from DIV assembly -

i have part of code mov di,3 mov cx,16 looop: xor dx,dx shl bx,1 adc dx,dx cmp cx,16 je cx16 (it's dec cx , jump loop) push dx dec cx cmp cx,0 je cx0 mov ax,cx div di cmp dx,0 jne looop when cx = 3 ax =3 div di ax become h=55 l= 56 , dx = 1 please tell me did wrong here? div di divides 32 bit quantity dx:ax di . don't know value bx has, presumably produces dx=1 (due adc dx, dx ). division going 0x10003 / 3 = 0x5556 remainder 1 , , that's see. ps: learn use debugger, , read instruction set reference appropriate.

ios - UICollectionView with Custom Layout Going Blank -

Image
i have built tv guide style application utilizes uicollectionview custom uicollectionviewlayout. custom layout uses 4 different custom uicollectionviewcells. have run interesting problem has stumped me , team. post quite long, done way give full context. if have time read , toss me ideas. appreciate it. always, community help. tl;dr - uicollectionview custom layout (subclass of uicollectionviewlayout) randomly loses data in view. goes blank. .reloaddata() called on viewdidappear , not fix. stumped cause. section 0, item 0 1 type of cell , kept in top left @ times. scroll, cell moved , kept in top left corner. section 0, item 1-n second type of cell , kept @ top @ times. section 1-n, item 0-n "stations", type of cell, , kept along left border @ times. all other cells "shows" , fourth type of cell , mapped specific x,y coordinate based on time , station. this collectionview performant , has allowed give great user experience part. however, when loade

Android Places Autocomplete set lat long bounds -

i using google places autocomplete api. application has autocomplete text view. working fine followed example here . only issue being setting latlng bounds of mountain view. private static final latlngbounds bounds_mountain_view = new latlngbounds( new latlng(37.398160, -122.180831), new latlng(37.430610, -121.972090)); my googleapiclient mgoogleapiclient = new googleapiclient.builder(this) .addapi(places.geo_data_api) .build(); when try enter new orleans address, have type lot not experience user out of ca. there better way set latlng bounds depending upon current location without asking location permission or precise location position. assuming not limitation of places api limited knowledge. thanks in advance. unfortunately no, need location permission since permission choose in manifest determines accuracy of location returned google api client. suggest using access_coarse_location accurate within 1 city block. here how

ajax - Can't get Access-Control-Allow-Origin header to work as I expected -

there lot of questions on subject, still can't seem resolve issue. i have game i'm trying working html 5 in chrome. link here . the game written using libgdx , i'm posting json data app engine hosted end. i've done quite bit of reading , think understand issue cross domain access, think understand how resolve can't. the full error is xmlhttprequest cannot load http://1-1-51.wordbuzzweb.appspot.com/login . no 'access-control-allow-origin' header present on requested resource. origin ' http://wordbuzzhtml5.appspot.com ' therefore not allowed access. as can see, says no 'access-control-allow-origin' header present on requested resource. . if @ headers requested resource, follows. date: thu, 18 jun 2015 21:59:34 gmt content-encoding: gzip server: google frontend vary: accept-encoding access-control-allow-methods: get, post content-type: application/json access-control-allow-origin: * alternate-protocol: 80:quic,p=0 cache-contr

excel - Unshare workbook everyday -

i want unshare excel workbook everyday @ 11:00pm. first use windows task scheduler open file @ 10:59:45pm, , run following code. following code work? sub unshare() application.displayalerts = false if thisworkbook.multiuserediting thisworkbook.exclusiveaccess application.displayalerts = true thisworkbook.close else application.displayalerts = true thisworkbook.close end sub sub workbook open() application.ontime timevalue("23:00:00"), "unshare" end sub also, of code located in thisworkbook. thanks! try using workbook_open event in private module of workbook object. private sub workbook_open( ) application.ontime timevalue("23:00:00"), "unshare" end sub

Jenkins GitHub pull request builder - get branch name for execute shell -

i using jenkins github pull request builder plugin running unit tests when pull request made vis vis web hook. build step, need know name of branch being merged in (e.g. need develop branch if merging master branch). there way access in jenkins execute shell? thanks, your link has answer: environment variables the plugin makes useful environment variables available. ghprbactualcommit ghprbactualcommitauthor ghprbactualcommitauthoremail ghprbpulldescription ghprbpullid ghprbpulllink ghprbpulltitle ghprbsourcebranch ghprbtargetbranch sha1 you'll want use $ghprbsourcebranch value of branch being built somewhere else in script.

matlab - What is the right way to add function handles recursive and see the right output after printing it? -

this tried: f = @(x) 0; = 1:n f = @(x) f(x) + x^i; end it seems right thing, when test putting in values. but when print f got output f = @(x) f(x) + x^i edit: how output want see, summands apear in function handle, when print f . you can use symbolic functions ( symfun ) want: % create symbolic variable syms x % define order of polynom n = 3; % create polynom fs(x) = 0*x; = 1:n fs(x) = fs(x) + x.^i; end % convert symbolic function function handle f = matlabfunction(fs) results in: f = @(x)x+x.^2+x.^3 edit: here approach without using symbolic math toolbox: % define order of polynom n = 3; % create polynom string fstring = '0'; = 1:n fstring = [fstring, '+x.^',num2str(i)]; end f = str2func(['@(x)',fstring]); results in: f = @(x)0+x.^1+x.^2+x.^3

angularjs - Adding query string to UI router route -

i have ui router route defined follows $stateprovider .state('search', { url: '/search', abstract: true, parent: 'loggedin', views: { wrapper: { controller: 'myctrl', controlleras: 'myctrl', templateurl: '/scripts/views/search/views/search.wrapper.html' } } }) .state('search.subs', { url: '', resolve: { isloggedin: isloggedin }, views: { body: { controller: 'searchbodyctrl', controlleras: 'searchbodyctrl', templateurl: '/scripts/views/search/views/search.body.html' } } }); anyways issue cannot generate query parameters url looks /search?

How to properly do dynamic memory allocation (C++) -

i trying create dynamically allocated array , print it's contents in c++. although code producing incredibly strange output when print. int main() { int* arr; arr = new int [1200]; memset(arr, 5, 1200); (int = 0; < 1200; i++) printf("%d ", arr[i]); std::cout << '\n'; return 0; } mixing cout , printf because playing around code. proper includes in file.\ here output: 84215045 84215045 84215045 84215045 84215045 84215045 84215045 84215045 84215045 84215045 84215045 84215045 1285 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i have no idea how produced. edit: thank answers. understand code , why output looks way look.great answers. memset(arr, 5, 1200); if scribble whole bunch of 5'a on piece of paper , try read paper, you'll things "5555". 84215048 in hex 0x05050505. don't manipulate arrays of data if raw chunks of memory unless know you'

sql - PIVOT XML - dynamic extracting field out to columns -

Image
i have posted original question on thread: pivot oracle - transform multiple row data single row multiple columns, no aggregate data enter link description here the results wanted achieved using statement: select * ( select "date", subcat,category,item,tag,value test2 tag in ('ln','sn') ) pivot ( max(value) tag in ('ln','sn') ) order category,subcat,item,"date" however, expand solution more flexible , accept dynamic selection in in clause. oracle not , threw out error. instructed use pivot xml. after research, came statement: select * ( select "date", subcat,category,item,tag,value test2 tag in ( select 'ln' dual union select 'sn' dual ) ) pivot xml ( max(value) tag in (any) ) order category,subcat,item,"date" but have extract out fields wanted not familiar how proceed. please help. the final result want still same: with pivot xml, got whole bu

c# - How to Download a Shared File on OneDrive for Business with the REST API? -

i trying download file shared folder appears in "shared me" folder of onedrive business. using following rest call folder name , files appear in it: https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(sharedwithusersowsuser:{useraccountname} , contentclass:sts_listitem_mysitedocumentlibrary) and https://{tenant}-my.sharepoint.com/_api/search/query?querytext='(parentlink:{parentlink})' with no issues. metadata supplied these calls, files in each directory , tried downloading them using following request calls (note "user1" person downloading file, "user2" person shared file): https://{tenant}-my.sharepoint.com/personal/user1_mydomain_com/_api/web/getfilebyserverrelativeurl('/personal/user2_mydomain_com/documents/test/test1.docx')/$value or https://{tenant}-my.sharepoint.com/_api/v1.0/user2_mydomain_com/files/{fileid} i have attempted use new v2.0 calls, don't seem support "shared me" folde

spring mvc - Intercept @RequestBody after serialization but before controller -

my request body objects implement interface call auditable, username , lastupdate timestamp set. intercept calls controller functions after serialization before hits controller can can these values in single place. i looked @ handlerinterceptor.prehandle method executes before serialization. suggestion on how can make happen? you can use controlleradvice , can in these scenarios. intercepts controller requests , can access serialized domain object in method. can pretty args requestmapping method takes. hope helps. @controlleradvice public class controlleradvisor { @modelattribute public void addattributes(httpservletrequest request, httpservletresponse response,model model, @requestbody domainobject domain) { domain.setusername("test"); // set other items want do. } }

java - Oracle ODI string literal mapping -

i'm looking whether or not oracle odi has capability needed organization etl(elt) operation. we need able create pairs of string literals mapping input string literal data source (excel file), different string literal in data target (oracle table). for example: excel file gender column value: "m" becomes oracle table gender column value: "male" after elt. does oracle odi have capability? yes, can it. odi allows choose microsoft excel data source (i not sure if allows .xlsx format, have not tried either). you have map excel sheet input, , can fetch data sheet, once have data in staging/temp table can transformation whatever , insert records final table. follow this link reference , try google step - - step move further answers specific questions.

Referencing a Cookie within a Header in JMeter -

within jmeter, able generate cookie , called cookie_testapi. can see value assigned cookie in debug sampler , wish use in header http requests. have http header manager specified follows: name: authorization, value: blah ${cookie_testapi}. but value of cookie not showing in http requests. getting authorization: blah ${cookie_testapi} , not referencing value of cookie. ideas on how can resolved? make sure have global http cookie manager in test plan , have cookiemanager.save.cookies=true set in properties file. isn't default.

Update entire colum in datatable jquery -

i using jquery datatable plugin , want update entire column values on click of button. how do that. i tried using fnupdate here need specify row , column. this html code table <table id="regions" class="display" cellspacing="0" width="50%"> <thead> <tr> <th>region</th> <th>min score</th> // want min max col editable <th>max score</th> //min < max </tr> </thead> <tbody> <% scores_row in scores_regions %> <tr> <td><%= label_tag 'regions[]',scores_row.at(0) %></td> <td>1</td> <td>1000</td> </tr> <% end %> </tbody> </table> this jquery code ,which applies second row

c# - Using IEnumerable.Except on KeyCollection vs. exploiting Dictionary.ContainsKey for mutual subtractions and intersection in relation to performance -

i have 2 dictionaries dictionary<string, object> . need find intersection (i mean keys intersection) , a\b , b\a subtractions , make actions objects (in fact objects entityframework entities , have mark state modified , added , deleted respectively, though it's not relevant question). imagine simplest venn diagram . i want efficient way. think have 2 choices: 1) implement set of generic extension methods internally operate ienumerable methods on keycollection exceptbykey , example: public static dictionary<tkey, tvalue> exceptbykeys<tkey, tvalue>(this dictionary<tkey, tvalue> dict1, dictionary<tkey, tvalue> dict2) { return dict1.keys.except(dict2.keys).todictionary(key => key, key => dict1[key]); } then operate these methods separately process each of 3 groups. there know keycollection.contains method internally uses dictionary<tkey, tvalue>.containskey method both o(1). except method run in o(n), is right? need u

ruby on rails - Rspec test public controller method passing params to private controller method -

this controller: class planscontroller def use_new_card @user = user.find_by_id(new_card_params[:user_id]) if new_stripe_card ... end private def new_card_params params.permit(:user_id, :stripetoken) end def new_stripe_card stripeservice.new({user_id: @user.id, customer_id: @user.stripe_customer_id, source: new_card_params[:stripetoken]}).new_card end end i'm trying write controller spec tests when proper parameters post use_new_card method, new_stripe_card 's stripeservice.new gets these parameters appropriately. my spec looks far: describe "when proper params passed" before @user = user.create(...) end "should allow stripeservice.new receive proper parameters" stripeservice.should_receive(:new).with({user_id: @user.id, customer_id: @user.stripe_customer_id, source: "test"}) post :use_new_card, user_id: @user.id, stripetoken: "test" end end but i'm getting

java - Constructor parameter injection using guice -

this different question other answered questions constructor parameter (or @ least that's think so, course may wrong). using mapbinder store bunch of implementations , pick 1 during runtime based of criteria. here code: public interface messageservice { void send(); } public class facebookmessageservice implements messageservice { private final string name; @inject public facebookmessageservice(string name) { this.name = name; } public void send() { system.out.println("sending message via facebook service " + name); } } public class messagemodule extends abstractmodule { @override protected void configure() { mapbinder<string, messageservice> mapbinder = mapbinder.newmapbinder<.....> mapbinder.addbinding("facebook").to(facebookmessageservice.class); } } public class messageclient { @inject map<string, messageservice> map; //mapbinder being injected public void callsender() { injector inj

I want to log data in a file which is displayed on java console when I run .jar file -

Image
i have .jar file executing java -jar file_name.jar . then program outputs ide console, prompt asking user credentials. after authenticating, program prints database data console. how can redirect console data output filestream? i tried adding logger while executing command java -jar file_name.jar . no success. i not java person, don't have idea how that. suggestion or great. edit screenshot addded gui screen if it's java console: java -jar class.jar <somefile.file> 1>> log.txt

How do I optimise this javascript function for speed? -

i took codility tape equilibrium test here as can see score didn't enough on how fast function executes. can give me pointers can optimise code , closer 100%? here code... function solution(a) { var minimumabsdiff = null; for(var currentindex =1;currentindex < a.length;currentindex ++){ var bottomhalf = gettotal(0,currentindex-1,a); var tophalf = gettotal(currentindex,a.length-1,a); var absdiff = math.abs(bottomhalf - tophalf); if(minimumabsdiff == null){ minimumabsdiff = absdiff; }else{ if(absdiff < minimumabsdiff) minimumabsdiff = absdiff; } } return minimumabsdiff; } function gettotal(start,end,arraytocheck){ var total = 0; for(var currentindex = start;currentindex <= end;currentindex++){ total = total + arraytocheck[currentindex]; } return total; } you don't want optimise speed. want lower algorithmic complexity . current algo

multi select spinner clearAll button android -

i'm creating multi select spinner , got problem clear button http://postimg.org/image/eoyq5jpib/ "select all" work pretty when clicked on "clear all" nothing happens. why i'm getting problem "clear all"? protected charsequence[] _options = { "one", "two", "three", "four", "five" }; protected boolean[] _selections = new boolean[ _options.length ]; protected button _optionsbutton; public class buttonclickhandler implements view.onclicklistener { public void onclick( view view ) { showdialog( 0 ); } } @override protected dialog oncreatedialog( int id ) { return new alertdialog.builder( ) .settitle( "students" ) .setmultichoiceitems(_options, _selections, new dialogselectionclickhandler()) .setpositivebutton("ok", new dialogbuttonclickhandler()) .setneutralbutton

c++ - How to trap memory reads and writes using sigsegv? -

how trick linux thinking memory read/write successful? writing c++ library such reads/writes redirected , handled transparently end user. anytime variable written or read from, library need catch request , shoot off hardware simulation handle data there. note library platform dependent on: linux ubuntu 3.16.0-39-generic #53~14.04.1-ubuntu smp x86_64 gnu/linux gcc (ubuntu 4.8.2-19ubuntu1) 4.8.2 current approach: catch sigsegv , increment reg_rip my current approach involves getting memory region using mmap() , shutting off access using mprotect() . have sigsegv handler info containing memory address, export read/write elsewhere, increment context reg_rip. void handle_sigsegv(int code, siginfo_t *info, void *ctx) { void *addr = info->si_addr; ucontext_t *u = (ucontext_t *)ctx; int err = u->uc_mcontext.gregs[reg_err]; bool is_write = (err & 0x2); // send data read/write simulation... // continue execution of program incrementing r