Posts

Showing posts from July, 2010

ios - Concern about memory when choosing between notification vs callback closure for network calls? -

many posts seem advise against notifications when trying synchronize functions, there other posts caution against closure callbacks because of potential inadvertently retain objects , cause memory issues. assume inside custom view controller function, foo , uses bar class data server. class customviewcontroller : uiviewcontroller { function foo() { // other stuff // use bar data server bar.getserverdata() } } option 1: define getserverdata accept callback. define callback closure inside customviewcontroller . option 2: use nsnotifications instead of callback. inside of getserverdata , post nsnotification when server returns data, , ensure customviewcontroller registered notification. option 1 seems desirable reasons people caution against nsnotification (e.g., compiler checks, traceability), doesn't using callback create potential issue customviewcontroller unnecessarily retained , therefore potentially creating memory issues?

android - accessing applicationStorageDirectory in Java -

i rewriting application written in adobe air - in native - java. there preferences stored in config.xml in applicationstoragedirectory still access in java code. know how access file in java? in air, applicationstoragedirectory resolves 1 of these paths, depending on os: windows 7 / vista: %userprofile%/appdata/roaming/ application name windows xp: %userprofile%/application data/ application name mac os x: ~/library/preferences/ application name linux (ubuntu): ~/.appdata/ application name android: /data/data/ application name

c - Not handling functions right -

my code supposed make simple menu change armor of character. code is: #include <stdio.h> #include <string.h> struct armor { char chestplate [50]; char helmet [50]; }; void changearmor (){ struct armor character; char [50]; printf("choose chestplate\n"); scanf("%s",&a); strcpy(character.chestplate,a); printf("choose helmet\n"); scanf("%s",&a); strcpy(character.helmet,a); menu(); } void checkarmor () { struct armor character; printf("your equipped chestplate is: %s\n", character.chestplate); printf("your equipped helmet is: %s\n", character.helmet); menu(); } void menu () { int a; printf("what want do?\n"); printf("1.change armor.\n"); printf("2.check current armor.\n"); printf("3.quit\n"); scanf("%d",&a); if(a==1) changearmor; // oops: should changearmor();

nio - Is Filewatcher considered non blocking IO in Java? -

this code snippet filewatcher java 7 nio library. non blocking code? threads waits signal filesystem. for (;;) { // wait key signaled watchkey key; try { key = watcher.take(); } catch (interruptedexception x) { return; } } filewatcher uses epoll linux system call. it's multiplexing mechanism event based. windows there select same thing, far less efficient , in bsd (which osx based on) there kqueue . in simple terms registers event handler in system waiting event occur. time progresses system takes @ queued event handlers , sees if there 1 ready proceed. if there event handler has it's event flag set true handle event. if there no events keep looping until finds event occurred. in meantime code in main continues run, giving "non-blocking" functionality in promises. this isn't new technology, although async has become quite popular rise of nodejs, swift , other non-blocking languages / frameworks same sort o

linux - multicast loopback in c -

i trying test multicast loopback clients join group , server multicast messgaes client in group constrained in 127.0.0.1 !!!!! refering : http://www.tenouk.com/module41c.html , source : the server : struct in_addr localinterface; struct sockaddr_in groupsock; int sd; char databuf[1024] = "multicast test message lol!"; int datalen = sizeof(databuf); int main (int argc, char *argv[ ]) { /* create datagram socket on send. */ sd = socket(af_inet, sock_dgram, 0); if(sd < 0) { perror("opening datagram socket error"); exit(1); } else printf("opening datagram socket...ok.\n"); /* initialize group sockaddr structure */ /* group address of 225.1.1.1 , port 5555. */ memset((char *) &groupsock, 0, sizeof(groupsock)); groupsock.sin_family = af_inet; groupsock.sin_addr.s_addr = inet_addr("224.0.0.0"); groupsock.sin_port = htons(4321); /* disable loopback not rec

jms - Cannot create ActiveMQ queue or send a message using java -

i'm new activemq. i'm running activemq server on windows using default settings on local machine. i've tried create simple queue test sending message. public class foo { public static void main(string[] args) { new foo().send(); } public void send(){ try { activemqconnectionfactory connectionfactory = new activemqconnectionfactory("vm://localhost:61616"); connection connection = connectionfactory.createconnection(); connection.start(); session session = connection.createsession(false, session.auto_acknowledge); destination destination = session.createqueue("testqueue"); messageproducer producer = session.createproducer(destination); producer.setdeliverymode(deliverymode.non_persistent); textmessage message = session.createtextmessage("message123"); producer.send(message); session.clos

Error Number 10170 in Verilog using If/Else and Case Statements -

i trying compile following code whenever errors: '10170 verilog hdl syntax error @ fsm.v(9) near text "case"; expecting operand' '10170 verilog hdl syntax error @ fsm.v(9) near text ")"; epecting "<=" or "="' '10170 verilog hdl syntax error @ fsm.v(11) near text "4"; expecting "end"' module fsm (in0, in1, in2, in3, s, out0, out1, out2, out3); input in0, in1, in2, in3, s; output out0, out1, out2, out3; reg out0, out1, out2, out3; @(in0 or in1 or in2 or in3 or s) begin if(s == 0) begin { case({in3, in2, in1, in0}) 4'b0000: {out3, out2, out1, out0} = 4'b0000; //0->0 4'b0001: {out3, out2, out1, out0} = 4'b0011; //1->3 4'b0010: {out3, out2, out1, out0} = 4'b0110; //2->6 4'b0011: {out3, out2, out1, out0} = 4'b1001; //3->9 4'b0100: {out3, out2, out1, out0} = 4'b0010; /

mongodb - Cannot insert form data into database using mgo in gin -

i'm new go , using gin framework trying create user object: const ( // collectionarticle holds name of users collection collectionuser = "users" ) // user table contains information each user type user struct { id bson.objectid `json:"_id,omitempty" bson:"_id,omitempty"` username string `json:"username" bson:"username"` email string `json:"email" bson:"email"` password string `json:"password" bson:"password"` statusid uint8 `json:"status_id" bson:"status_id"` createdat time.time `json:"created_at" bson:"created_at"` updatedat time.time `json:"updated_at" bson:"updated_at"` deleted uint8 `json:"deleted" bson:"deleted"` } this controller create user // create user func create(c *gin.context) { db := c.mustget

mysql - Join two tables by row -

have 2 tables same column need merge 2 table below table1 id name 1 test1 4 test7 5 test9 6 test3 table2 id name 2 test2 3 test5 6 test3 result id name 1 test1 2 test2 3 test5 4 test7 5 test9 6 test3 so need join/merge 2 tables id , can see id 6 present in both table need override table 2 value , give above result. kindly me solve issue. thank you. select id,name table1 union select id,name table2 ; other way select * ( select id,name table1 union select id,name table2)temp order temp.id ; this arrange records id wise union eliminate duplicate record , in case it's id 6

ios - How to make uiimageview circle.? -

i need make uiimageview in circle radius, using block of code taks. -(void)viewwillappear:(bool)animated { [self performselector:@selector(setstylecircleforimage:) withobject:_imageview afterdelay:0]; [super viewwillappear:yes]; } -(void) setstylecircleforimage:(uiimageview *)imgview { imgview.layer.cornerradius = _imageview.frame.size.height / 2.0; imgview.clipstobounds = yes; } its working perfect in ios 5 when test in other device shape change don't know why happens. please make help. better use mask make circle function - (void)viewdidload { [super viewdidload]; [self makecircleimage: _imageview]; } -(void)makecircleimage:(uiimageview *)img{ cgfloat img_width = img.bounds.size.width; uigraphicsbeginimagecontextwithoptions(cgsizemake(img_width,img_width), no, 0); cgcontextref c = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(c, [uicolor blackcolor].cgcolor); cgcontextfillellip

javascript - How to make circle to appear one after another using d3 transition? -

i following circle example : i created circle below, , wish make opacity transition data set updates, circle start appearing 1 after another. example, if data length 5, circle 1 appears, circle 2, ... circle 5. , if data updated length 2, circle 1 appears, circle 2 appears. how do effect? far, transition() works on data set uniformly. circle.enter().append("circle") .attr("class", "dot"); // update (set dynamic properties of elements) circle .attr("r", 5) .attr("cy", 20) .attr("cx", function(d,i){return i*50;}) .attr("fill", "red"); svg.selectall("circle") .style("opacity", 0) .transition() .duration(1000) .style("opacity", 1); problem: setting delay each element in "transition" selection. solution: use delay() function(d, i) instructions: you have add

last modified files only moved ansible? -

my requirement moving files remote host using ansible playbook. my ansible script --- - hosts: webservers remote_user: root tasks: - copy: src=/home/bu/bilal/site dest=/tmp owner=root group=root mode=777 when run playbook has moved file remote. when have ran playbook again overwrite whole folder again. looking, files have modified files overwrite because folder size large taking time single file change. take @ synchronize module: uses rsync make synchronizing file paths in playbooks quick , easy. example: - name: sync files synchronize: src: "{{ conf.dev_path }}/" dest: "{{ conf.host_path }}" delete: yes rsync_opts: - "--exclude=.*"

How can I merge multiple matrices of different dimensions in R -

this question has answer here: simultaneously merge multiple data.frames in list 7 answers i have these matrices of different dimensions. key.related.sheet column in matrices have common , uniques values. want match common rows , merge 3 matrices, want include unique rows well. result column should have key.related.sheet , sample_b , trace_1 , trace_2 , trace_3 columns only. can please me this? aa<-structure(c("s05-f13-p01:s05-f13-p01", "s05-f13-p01:s08-f10-p01", "s05-f13-p01:s08-f11-p01", "s05-f13-p01:s09-f66-p01", "s05-f13-p01", "s08-f10-p01", "s08-f11-p01", "s09-f66-p01", "1.25", "0.227", "-0.183", "-0.217"), .dim = c(4l, 3l), .dimnames = list(null, c("key.related.sheet", "sample_b", "trace_1"))) bb

c++ - Implementing selection sort on a singly linked list -

heya i'm trying implement selection sort algorithm on singly linked list , i'm aware there problem in code although linked list includes numbers 7 1 2 6 output after running 7777 . appreciated. template<class type> void unorderedlinkedlist<type>::selectionsort() { nodetype<type>* loc; nodetype<type>* minindex; nodetype<type>* temp; temp = first; if(temp == null) cerr<<"cannot sort empty list."<<endl; else if(temp->link == null) cerr<<"list has 1 item sorted."<<endl; else while(temp != null) { minindex = minlocation(temp, last); swap(temp, minindex); temp = temp->link; } } template<class type> nodetype<type>* unorderedlinkedlist<type>::minlocation(nodetype<type>* first, nodetype<type>* last) nodetype<type>* minindex; nodetype<type>* other; minindex = first; other = minindex->link; while(other != null) { if(minindex

c# - Encoding for international character -

Image
i making google suggestion api and requtesting "¿cómo estás" word should have return ¿cómo estás ¿cómo estás hoy ¿cómo estás meaning ¿cómo estás tú ¿cómo estás cuando nadas ¿cómo estás yo (1) ¿cómo estás yo ¿cómo estás response ¿cómo estás in english but showing [{"phrase":"como estás"},{"phrase":"cómo estás en inglés"},{"phrase":"como estás em espanhol"},{"phrase":"cómo estás lleva acento"},{"phrase":"cómo estás tú"},{"phrase":"cómo estás hola"},{"phrase":"como estas means"},{"phrase":"como estas reply"},{"phrase":"como estas usted"},{"phrase":"como estas hoy"}] and response is ignore keywords. you can see ¿ is missing in result my code system.net.httpwebrequest request = webrequest.create(url) httpwebrequest; re

android - Is spanning of texts inside EditText possible? -

i have looked high , possibly low find solution still doesn't seem work. keep looking solution can find on google " how span textviews" additional notes have tried following is possible have multiple styles inside textview? android: coloring part of string using textview.settext()? android: coloring part of string using textview.settext()?

How To View 3D Buildings in My Google Maps Application On Android -

this first question on english stackoverflow(i'm japanese), i'm not used writing english , not @ english.sorry. i want ask google maps api v2 on android.i created simple map application, , want show 3d buildings. show map, can not view 3d buildings. i know have drag 2 fingers down on display show 3d buildings. this code. private void mapinit() { ismapinit = true; //get locationmanager locationmanager = (locationmanager)this.getsystemservice(context.location_service); //get location information gps location mylocate = locationmanager.getlastknownlocation("gps"); // set map type googlemap.setmaptype(googlemap.map_type_normal); googlemap.setbuildingsenabled(true); boolean test = googlemap.isbuildingsenabled(); // show button of location googlemap.setmylocationenabled(true); mlocationclient = new googleapiclient.builder(this) .addapi(locationservices.api)

Setup review targets for branches in git -

i have created branch locally using command - git checkout -b <branch> made remote branch using command - git push -u origin <branch> i trying set review targets branch using command - git reviewtargets <branch> but message saying - 'reviewtargets' not git command . how can setup review targets branch have created? any git xxx command (which not native git feature) supposes presence of executable named git-xxx (no extension) anywhere in $path . make sure have git-reviewtargets in path.

Calling Perl Scripts from a Perl script given the scripts are in an array -

i have list of perl scripts sample_1.pl , sample_2.pl & sample_3.pl. stored in array my @scripts ( sample_1 => "this script number 1 ", sample_2 => "this script number 2 ", sample_3 => "this script number 3 " ) now how call these scripts using foreach loop firstly, it's not clear whether want store commands in array or hash. 2 data structures different in perl. in code, store commands in array ( @scripts ) initialise array using hash-like syntax ( (key => value, ...) ). syntax work, doesn't (i think!) want do. end keys in array, , it's hard skip them. if want store commands in array, this: my @scripts = ( "this script number 1 ", "this script number 2 ", "this script number 3 " ); system($_) @scripts; if want store them in hash reason, store them in has , use hash function values want. my %scripts = ( # %, not @ hash sample_1 => "this script n

ANDROID: ImageView for different sizes -

Image
i new android studio; please excuse if query trivial. problem understanding layouts. my layout , corresponding values folder shown below. problem correct layout not being picked up. example, nexus 4 (4.7inch, 768x1280, xhdpi), in landscape mode, layout being picked 'layout' folder. per understanding (which might totally wrong :) ) should have been picked layout-sw720dp-xhdpi. suggestions please? layout-problem sw stands smallest width . if device has width of 320dp in portrait mode , 720dp in landscape mode end device's smallest width 320dp. try use layout-w720dp-xhdpi instead of layout-sw720dp-xhdpi , see if works. how calculate device dimensions in dp calculate ppi (pixel per inch) of device. calculate dimensions of device using dp where: = screen width in pixels = screen height in pixels = screen diagonal in pixels = pixels per inch = screen diagonal in inches edit: according wikipedia "the nexus 7 (2013) screen has

python - Bypass/Ignore "no audio device" error -

this known problem windows users, can't watch youtube or play/use applications, because don't have audio device , app shows error messages or crashes. i want avoid on python game making, couldn't find useful on web, has solution?

mysql - How to count no of student got registered for a particular course for the below two given table? -

enter image description here here have write sql query in order count number of students registered particular course taking "examseriesname" user input user interface. using mysql query browser: the following different table details: create table tblcourse ( courseid numeric(8) primary key, cname varchar(20), uid numeric(8), numberofyears numeric(8), coursecode varchar(8) ); create table tblstudent ( regid numeric(8) primary key, sid numeric(8), sname varchar(20), year varchar(4), courseid numeric(8), branchid numeric(8), uid numeric(8), collegeid numeric(8) ); create table tblexamseries ( id numeric(8) primary key, monthandyearofexam date, examseriesname varchar(20), serieslastdate date, chalanlastdate date ); sorry yesterday have not mentioned other 2 table. today sir told should correct query sharing ans all. support. select cname, count(*) from tblstudent st, tblstudentdetails s

How to query 3 month running average from SSAS Multidimensional Cube (MDX) for each date? -

Image
i have ssas multidimensional cube , need query 3 month running average each day in date range . for example, 2016-04-25 must data from 2016-01-01 2016-03-31 . can't use query (because don't know how days must lag till previous month): with member [measures].[salesamount 3m average] ( sum( ([date].[date].currentmember.lag(90) : ([date].[date].currentmember.lag(1), [measures].[salesamount] ) ) i guess need use ancestor function month , use lag month granularity. ok, let's try one: with member [measures].[salesamount 3m average] ( sum( (ancestor ( [date].[date].currentmember, [date].[month] )).lag(3) : (ancestor ( [date].[date].currentmember, [date].[month] )).lag(1), [measures].[salesamount] ) ) select { [measures].[salesamount 3m average] } on columns, { [date].[date].&[2016-01-01t00:00:00] : [date].[date].&[2016-02-28t00:00:00]} on rows [cube] unfortunately, query doesn't work (returns null). how solve problem?

ios - Navigation like in the mail app with segues and dynamic cells in a table view? -

i'm developing first ios app college. when start app, there grouped table view should represent menu. works fine far, i'm unable connect segues properly. far know should connect cell navigation controller should lead to. although every cell should lead navigation controller. it's menu, point should clear. unfortunately i'm unable connect single cell multiple navigation controllers , when add multiple prototype cells, have problem every cell should have it's own identifier. the first screen see in app looks mail app. there 2 groups , each cell leads navigation controller. i managed implement navigation in weird way, lot of bugs "nested push results in corrupted nav bar". i'm absolutely frustrated right now, spent lot of hours on single problem , i'm unable find solution. edit: 1 of biggest problems if navigate point , head the view before, grouped view first displayed close top , when animation complete whole view jumps down belongs. t

iphone - iOS addSubview & removeFromSuperview causing memory leaks -

i have following issue: i have 1 instance class extends uiviewcontroller class, in class adding uiimage uiimageview, , adding uiimageview self.view using method "addsubview:" [self.view addsubview:imageview] , adding self.view window using [[[uiapplication sharedapplication] keywindow] addsubview:[self view]] , , when click on close button clearing self.view (removing subview "uiimageview") , removing self.view window. now issue when using same instance add other uiimageview other image, first data not freed memory have released them , removed them superview. following code illustrates problem. - (void) setimagewithurl: (nsstring *)url { nsdata * imagedata =nsdata * imagedata =[nsdata datawithcontentsofurl:[nsurl urlwithstring:url]]; if (imagedata) { uiimage *image = [[uiimage alloc]initwithdata:imagedata]; [[[uiapplication sharedapplication] keywindow] addsubview:[self view]]; [self createviewwithimage:image]

class - How to create a custom type declaration(type hinting) in PHP -

i have seen in few mvc frameworks class hotel{ function add(addrequest $post){ $this->save($post->all()); } } i create own type hinting using php class bellow , know there 2 ways it. with class: public function myfunction(someclass $instance) with interface: public function myfunction(someinterface $instance) i couldn't find article it.can explain briefly on how create our own type hinting , advantages doing so. the first benefit of using type hinting validation , self-documentation comes i.e. if come code haven't seen in while or working on else's code able see straight away must passed instance of specific. second being, if not pass required instance throw error. (this without code) furthermore, use of interfaces allows different implementations of class passed through code allow because interface should declare required methods (think different db drivers). i've not used yii before don't know it. laravel, on other hand, work

c# - Stalling time for all requests only on chrome -

i started working on improving speed of company online system first thing noticed every request stalling time of 150-200 ms, , since system kinda poorly built lot of use of iframes page require 20 resources 4 sec delay because of stalling alone. here screenshot of looks image i got no idea causing appreciated. some information might help: this behavior happen in chrome no such delays can seen on firefox example. the system built using asp.net c#. the system hosted in germany , connecting israel. you using devexpress somewhere in page.... , believe might issue. give try in here: " https://www.devexpress.com/support/center/question/list/1 " other noticeable aspect: caching of of .js, .css, etc static files??? take on that...

amazon web services - RabbitMQ Cluster in Docker Container among different hosts -

i want create rabbitmq cluster resilient failures. so far i've managed create cluster 3 nodes, each of these nodes runs inside docker container. enable nodes join cluster, hosts needs know each other via links. now, whole architecture runs in cloud (on aws precise). far, containers can linked 1 another, when run on same aws-instance. want create cluster in way nodes can lie on diffrent hosts. so far i've tried: using federation / shovel instead. not serve purpose, because need cp cap-theorem , not ca. need nodes replicas of 1 , able act same broker clients. creating docker swarm. able set-up docker swarm , connect 2 instances via docker swarm. if try run multiple rabbit-containers on swarm, either placed on same node or cannot link them 1 another. end same constellation, of hosts running on same node. is there solution or other approach, create rabbitmmq-cluster inside docker containers among different aws-instances / hosts? you mentioned "to enab

set - Combining/concatenating more than two expressionsets in R -

i have several expressionsets (eset) combine together. found package combine 2 esets have around 10 esets want combine. here package combines 2 esets example: library('a4base') ## not run: # prepare , combine 2 expressionset data(data.h2009); data(phenodata.h2009) data(data.skov3); data(phenodata.skov3) eh2009 <- prepareexpressionset(exprs = data.h2009, phenodata = phenodata.h2009, changecolumnsnames = true) eskov3 <- prepareexpressionset(exprs = data.skov3, phenodata = phenodata.skov3, changecolumnsnames = true) newe <- combinetwoexpressionset(eh2009,eskov3) ## end(not run) is there way combine them @ once? thanks in advance, i've found solution. there package called insilicomerging. i post answer in case 1 has problem mine. take @ this: insilicomerging

angularjs - Missing step attribute error message in input -

angular js provide validation several html5 introduced attributes of input, min or required including . <input type="number" name="input1" id="input1" min="0" ng-model="$ctrl.input1"ng-required /> <div ng-messages="formname.input1.$error" class="em-messages"> <div ng-message="required">this value required</div> <div ng-message="min">you must not use negative values</div> </div> for step attribute such validation working, no error message can displayed material way default, what's easiest way implement (for example step="0.001" ? <input type="number" name="input1" id="input1" min="0" step="0.001" ng-model="$ctrl.input1"ng-required /> <div ng-messages="formname.input1.$error" class="em-messages"> <div ng-messag

php - No logged in user in Authenticate middleware but in other Middlewares -

introduction problem is, have no logged in user when trying use auth middleware restrict route logged in users have 1 when getting redirected login page. details let's assume have these 2 routes route web middleware $router->group(['middleware' => 'web'], function($router) { /** @var registrar $router */ $router->get('/', ['as' => 'home', 'uses' => 'homecontroller@index']); }); route auth middleware $router->group(['middleware' => 'auth'], function($router) { $router->get('/listings', ['as' => 'listings', 'uses' => 'listingcontroller@index']); }); the first route works without problems, second route redirects me login page. should done, when have no logged in user, logged in before! weird. when add these 2 lines of code handle function of middleware illuminate\cookie\middleware\addqueuedcookiestoresponse us

How to encapsulate height and width of an image with java.awt.Dimension object and pass it to a method like 235 x 265 -

java: how can encapsulate height , width java.awt.dimension object (in java) 235 x 265 , and pass method. passed integer array? if so, how? contributions highly appreciated. objects meant used types variables, , can of course passed arguments methods. here's example: public class dimensionprinter public void printdimension(dimension d) { system.out.println("here's dimension width : " + d.getwidth()); system.out.println("here's dimension height : " + d.getheight()); } } and here's example using above method: public class main { public static void main(string[] args) { dimension dimension = new dimension(800, 600); dimensionprinter printer = new dimensionprinter(); printer.printdimension(dimension); } } (imports omitted) this extremely basic stuff need understand before doing serious development, gui development, hard. if learnt answer, it's sign should read introducto

xml - Are the attributes of an HTML-element part of the tag? -

i've got prepare workshop html-beginners , came across on following. if have ... <p>this text-node.</p> ... <p> , </p> tags. whole thing '<p>this text-node.</p>' element. so far, good. but when i've attributes in '<p class="foobar">this text-node.</p>' ... is attribute part of tag? means: tag opening bracket closing bracket including attributes? or have got wrong? please correct me. your understanding correct. attributes declared within start tag part of start tag. true in both html , xml . to clear, attributes pertain element, , not tag, since tag element declaration if (for lack of better term). however, attr=value notation indeed part of start tag. for purposes of introductory workshop, distinction in attributes not important. what's more important (and mean very important) distinction between elements , tags.

html - How to send radio button value with AJAX and recover it with PHP -

i've been trying send value of radio button selected user , recover value php, problem can't recover value. here's code: html <form name="submission" action=""> <input type="radio" name="ex1" id="ex1_a" value="1"> <input type="radio" name="ex1" id="ex1_b" value="2"> <input type="radio" name="ex1" id="ex1_c" value="3"> <button class="buttons" type="submit"> submit </button> </form> jquery script w/ ajax $(function() { $(".buttons").click(function() { // validate , process form here var radio_button_value; if ($("input[name='ex1']:checked").length > 0){ radio_button_value = $('input:radio[name=ex1]:checked').val(); }

Stubbing of mockito mock object on spock-based test -

i'm using spock fw mockito. have controller named 'hostcontroller' , service named 'hostservice'. the 'hostcontroller' has method called host(long id) , 'hostservice' has method called findone(long id) . i want test hostcontroller#host(long id) , think of stubbing findone(long id) method. follow test code: class mocktest extends specification { @mock private hostservice mockedservice; @injectmocks private hostcontroller controller; def setup() { mockitoannotations.initmocks(this); } def "mock test"() { given: def host = new host(id: 1, ipaddress: "127.0.0.1", hostname: "host1") mockedservice.findone(_) >> host when: map<string, object> result = controller.host(1) then: result.get("host") != null } } in above test, controller.host(1) return map<string, object> type , has key na

angularjs - Javascript and AngularJS2. Why javascript script fires too early and suppose not working. -

i have problem javascript script. have programmed in javascript , problem hadn't shown up. writing website angular , javascript , not working quite well. first when trying put <script></script> in component template not run. next problem forced put link external script in index , script looks that: $(window).load(function() { $(".home_page_well").css({opacity:0.5}); $("#system_epop_h6").hide(); $("#kto_moze_korzystac_h6").hide(); $("#co_zrobic_uzytkownik_h6").hide(); }); html looks that: <div class="col-sm-12 home_page_well system_epop"> <img src="assets/img/question_mark.png" alt="co jest?" class="img-rounded home_img center-block"/> <h4> czym jest system epop? </h4> <h6 id="system_epop_h6"> system epop jest platformÄ… po

regex - Backslashes in regexp pattern for PHP -

i'm trying perform regex operation in php code (preg_replace). i'm working with: |^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i that matches urls http://google.com , etc... i'm guessing if url want match one? http:\/\/asd.domain.com\/path\/of\/url\/something.else i've tried 2x backslashes , 4x backslashes , doesn't seem work. any advice? thanks in advance. well, if want match string, add backslashes: ^http(s)?:\\?/\\?/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\\?/.*)?$ i used ? quantifier still matches urls match before that. since \ escaping character, need 2 of those, first escape escaping properties of second \ . see demo (i escaped forward slashes there because of how regex tester works -- delimiters slashes).

objective c - -[UINavigationController <null selector>]: unrecognized selector sent to instance -

apologies if duplicate. if thankful link , happy delete question. however, did not find answer between tons of search results. not usual case of unrecognized selectors. selector nil. , thrown on line: return self.topviewcontroller; that line embedded in: @implementation uinavigationcontroller (jtrevealsidebarv2) - (uiviewcontroller *)selectedviewcontroller { return self.topviewcontroller; } @end as see attempt extend uinavigationcontroller . may have noticed code based on turorial: https://github.com/mystcolor/jtrevealsidebardemo (based on demo of version 2, if interested). as far have noticed have not yet made change mystycolor's framework. not uiviewcontroller+jtrevealsidebarv2.h nor .m . far made changes 1 of 2 view controllers, presented. those, contain contents, not navigation logic. apparently method being called. therefore category must have been used in correct way? , mystycolor using there, calls documented method , returns value. tutorial, forei

groovy - How to perform actions for failed builds in Jenkinsfile -

is there way perform cleanup (or rollback) if build in jenkinsfile failed? i inform our atlassian stash instance build failed (by doing curl @ correct url). basically post step when build status set fail. should use try {} catch () ? if so, exception type should catch? i'm searching solution problem. far best come create wrapper function runs pipeline code in try catch block. if want notify on success can store exception in variable , move notification code block. note have rethrow exception jenkins considers build failed. maybe reader finds more elegant approach problem. pipeline('linux') { stage 'pull' stage 'deploy' echo "deploying" throw new filenotfoundexception("nothing pull") // ... } def pipeline(string label, closure body) { node(label) { wrap([$class: 'timestamperbuildwrapper']) { try { body.call() } catch (exception e) {

javascript - Modify Select2 search box -

Image
i using ajax feature of select2 control load options asynchronously. however, change default template of search box have placeholder , icon on right. is there proper way that? placeholder: example: $(".js-example-placeholder-single").select2({ placeholder: "select state", allowclear: true }); custom icon: you can append using js. create dom element, append want , style css. of course can add additional functionality if needed. http://www.w3schools.com/jsref/met_node_appendchild.asp

c# - How to log full raw WCF client request from client side? -

i have wcf client transportwithmessagecredential security mode. when try log request using beforesendrequest public object beforesendrequest(ref message request, iclientchannel channel) { system.io.streamwriter file = new system.io.streamwriter("c:\\tmp\\request_log.xml"); file.writeline(request.tostring()); file.close(); return null; } have result without security tags <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:header> <action s:mustunderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">https://(skiped)</action> </s:header> <s:body> ... </s:body> </s:envelope> how can log full raw request in client? must this <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity

how to redirect/dispatch in php? -

this question has answer here: how make redirect in php? 24 answers i working on login functionality. want is, on form submission "login.php" if details correct should go "home.php" else should go "login.php" . login processing on "process.php" . don't know how redirect/dispatch appropriate page "process.php" use header function this: header('location: login.php'); exit; but don't print html output before calling header function else result in error.

android - The configuration of mediaRecorder -

Image
i want record video in lapses in android using mediarecorder unable set correctly. removing setprofile() , setcapturerate() works fine manually, want capture in lapses

How to reimplement the "all" function in Haskell? -

i need define function all' :: ( -> bool ) -> [a] -> bool verifies if elements list satisfy condition . for example : all' ( <5) [1,2,3] = true , all' (>=2) [1,1,2,2,3,3] = false. my main problem don't know how handle transmission of function. functions in haskell passed other value. here's example progress: dobothsatisfy :: (a -> bool) -> -> -> bool dobothsatisfy p x y = (p x) && (p y) and usage: dobothsatisfy (> 5) 6 7 == true dobothsatisfy (> 5) 1 8 == false now try extend lists.

php - Sonata Admin render "with" of Child -

i added field contact (type: sonata_type_admin) adminclass entity activity. my contactadmin looks that: protected function configureformfields(formmapper $formmapper) { $formmapper ->with('adresse', array('class' => 'col-md-6')) ->add( 'location.address', addresstype::class, array( 'label' => 'adresse' )) ->end() ->with('contact', array('label' => 'contact')) ->add('name', 'text') ->add('email', 'text') ->add('websiteurl') ->add('description') ->add('telephonenumber') ->add('telefaxnumber') ->end() ; } in activityadmin added that: $formmapper->add('contact', 'sonata_type_admi

android - how do i set my screen for tablet? -

this xml code below make app tablet how set layout? change image button position when moving portrait landscape mode (green color button) , space in between 4 image icon , playstore icon when in portrait how reduce this?? me please images http://imgur.com/eks82xc , http://imgur.com/2piea8k want show green button below header right side above 4 icons button , reduce gap in between 4 icon , googleplay store icon how do this? change position when moving portrait landscape make tablet 1024 600 resolution <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/home_bgg" android:orientation="vertical" >

php - Trouble connecting to mysql database when using a config file -

i can't connect database when use these files. here php code. the db_config.php file: <?php define('db_user', "root"); define('db_password', "mypassword"); define('db_database', "mydbname"); define('db_server', "localhost"); ?> the db_connect.php file: <?php class db_connect { //constructor function __construct() { $this->connect(); } //destructor function __destruct() { $this.close(); } function connect() { // import database connection variables require_once __dir__ . '/db_config.php'; $con = mysql_connect(db_server, db_user, db_password) or die(mysql_error()); $db = mysql_select_db(db_database) or die(mysql_error()); // returing connection cursor return $con; }