Posts

Showing posts from August, 2011

ios - How to write unit test for testing view controller? -

we trying write our custom unit tests testing every view controller separately. know there ui automation, kif, , other solutions, if take @ code above find should possible without using them. so, simplicity, suppose there's simple view controller 2 public methods "setfirststate" , "setsecondstate". need test, "setfirststate" method called when view controller instantiated , shown on screen (goes through viewdidload). here's demo view controller: @interface myviewcontroller - (void)setfirststate; - (void)setsecondstate; @end @implementation myviewcontroller - (void)viewdidload { [super viewdidload]; [self setfirststate]; } @end so, unit test testing setfirststate call (using xctest , ocmock): - (void)test_viewdidload_callsmymethod { myviewcontroller *viewcontoller = [[myviewcontroller alloc] init]; id mock = [ocmockobject partialmockforobject:viewcontoller]; [[mock expect] showlogin]; [uiapplication sha

actionscript 3 - How to convert flash dynamic presentation to air to work in mobile -

can convert flash desktop presentation developed in flashdevelope as3 air work in mobiles(ex: android) phones. presentation containes runtime dynamic data(xmls,images,swfs) loading. possible? you can load static assets no problem, loading remote swf containing actionscript isn't allowed on ios , android have restriction. for new version of air can package code in main swf , load swf , linking code. see article more details. adobe article you can package multiple swf in application , load them. adobe article

php - Query multiple tables - display Team Name based on Team ID -

my tables structures are `tblteam` (`teamid`, `teamname`) values (1,'india'), (2,'pakistan'), (3,'brazil') (4,'poland'); `tblmatch` (`matchid`, `matchdate`, `matchstart`, `matchend`, `team1id`, `team2id`) values (1, '19-11-2014', '12:00:00', '13:00:00', 1, 2), (2, '19-11-2014', '13:10:00', '14:10:00', 4, 3), (3, '19-11-2014', '14:20:00', '15:20:00', 1, 3), (4, '19-11-2014', '15:30:00', '16:30:00', 4, 2), (5, '20-11-2014', '10:00:00', '11:00:00', 1, 4), (6, '20-11-2014', '11:10:00', '12:10:00', 3, 4); insert tblscore ( scoreid , teamid , matchid , score ) values (1, 1, 1, 5), (2, 2, 1, 6), (3, 4, 2, 15), (4, 3, 2, 26); i want display team name of ( team1id , team2id ) on 19-11-2014 there 4 matches in php output should time : between : 12:00:00 - 13:00:00 india v/s pakistan

javascript - The Mathematical Operators not working on window.innerWidth -

when use mathematical operators window.innerwidth returs nan. i tried add numeric 1 window.innerwidth. what's wrong code? <body> <p>click button display window's height , width (not including toolbars , scrollbars).</p> <button onclick="myfunction()">try it</button> <p id="demo"></p> <script> function myfunction() { var w = window.innerwidth; var h = window.innerheight; x = document.getelementbyid("demo"); x.innerhtml = "width: " + w-1 + " heigth: " + h; } </script> </body> view sample @ plunker change innerhtml code as x.innerhtml = "width: " + (w-1) + " heigth: " + h; modify javascript code below here modified plunker function myfunction() { var w = window.innerwidth; var h = window.innerheight; x = document.getelementbyid("demo"); x.innerhtml = "width: " +

rest - Retrieving all(!) of the tweets of a user -

i want tweets of user using twitter api 1.1 , end point: https://api.twitter.com/1.1/statuses/user_timeline.json the documents of twitter api https://dev.twitter.com/rest/reference/get/statuses/user_timeline says there's limit 3200 (the parameter count ). if that's case, how retrieve all(!) of tweets of user, not 3200? the simple answer cannot. the longer answer there 2 ways around this. the user can request twitter archive. contain list of every tweet have sent. the new search api indexes every tweet. can, theoretically, search each tweet. however, if don't know you're searching for, it's unlikely work.

xcode6 - Store data in Swift -

i have general question on programming related swift. example when want store int value in app because use variable along whole application. have 3 options this: //first //in appdelegate var myint = 3 //and later can use when let delegate = uiapplication.sharedapplication().delegate appdelegate delegate.myint = 5 //second //i can store value in userdefaults nsuserdefaults.standarduserdefaults().setinteger(myint, forkey: "myint") nsuserdefaults.standarduserdefaults().synchronize() //and later them var anotherint = nsuserdefaults.standarduserdefaults().integerforkey("myint") //third //i can define structure data storage struct mydata { static var myint = 3 } //and later value mydata.myint = 5 so question is, 1 should use? or shouldn't 1 store global values @ all? love hear :] option 1 work fine if don't want variable persist between app launches. option 2 work fine if do want variable persist between app launches. option 3 work not

php - I am getting Fatal error: Using $this when not in object context -

hi using code below, know works in page on site, purpose have put within standalone button runs script server side, not working , getting fatal error: using $this when not in object context (the $$postcode= $params["value1"]; result previous javascript fetches current field (postcode) add screen, works , tested, rest of code. id grateful alternatives? $postcode= $params["value1"]; //set post code variables $key = "xxxx-xxxx-xxxx-xxxx"; $searchterm = $postcode; $this->key = $key; $this->searchterm = $searchterm; //build url request $url = "http://services.postcodeanywhere.co.uk/postcodeanywhere/interactive/find/v1.10/xmla.ws?"; $url .= "&key=" . urlencode($this->key); $url .= "&searchterm=" . urlencode($this->searchterm); //make request postcode anywhere , parse xml returned $file = simplexml_load_file($url); //check error, if there 1 throw exception if ($file->columns->column->attrib

javascript - validate mulitiple date fields -

i'm creating form have datepicker , timepicker both starting date , ending date. in total got 4 fields. able validate if startdate (a combination of startdate , starttime) earliere enddate. can't seem figure out , how should put validation. so whenever 1 of fields edited should trigger validation. i can't seem figure out , how create validation, i've tried create custom validation named method-validation retrieve method controller decided if validation propper, can't put on 1 field, because if change other field validation not triggered. anyone have idear working ? bottom line is, want able take 2 , 2 fields set them togehter, , compare them, , show message if end smaller start. follow up: the issue isn't comparing 2 dates. can achieve. <input type="text" ng-model="activity.startdate" date-picker> <input type="text" ng-model="activity.starttime" time-picker> <input type="text"

browser - Can a site use other site's cookie? -

say, site example.com stores cookie named id . now, can site access cookie named id ? browsers should never send cookies sites on different domains (third parties) originator (first-party), depending on how domain set in cookie might passed other subsites (e.g. cookie domain .example.com originating me.example.com sent you.example.com, them.example.com, etc).

amazon web services - Deploying a PHP/MySQL Application in Cloud (AWS) -

how deploy application (in case php , mysql based) in multiple server environment. specific, application supposed deployed per below mentioned configuration. mysql on amazon rds application (php) on 2 ec2 instances mysql part obvious need clarity on how deploy application on 2 servers. understand need setup application on both ec2 instances , somehow aws elastic load balancing automatically balance load. are there specific configuration/code changes need make in application work in such environment? in case application based on either cake or yii. cloud ready default? if not, changes, if any, needed. essentially, looking guide or instructions clarifies such doubts , helps me deploy application per above mentioned configuration. i'm using capistrano when deploy yii application multiple ec2 instances. i think following article : deploy php websites using capistrano (and git) | fred wu's blog http://fredwu.me/post/720733257/deploy-php-websites-using-c

javascript - Angular date error -

in angularjs i'm trying use date() function milliseconds '2014-11-19 10:58:16' with function var n = new date.parse('2014-11-19 10:58:16'); but i'm getting weird error typeerror: function parse() { [native code] } not constructor how can fix this? as frédéric hamidi posted in comment shouldn't have used new date but date thank frédéric hamidi

css - Ways to set div width and height dynamically -

scenario 1: top header 100% width , 50px height. left navigation bar 200px width , dynamic height fill screen. body{ padding: 0; margin: 0; } .header{ width: 100%; height: 50px; } .navbar{ position: absolute; top: 50px; bottom: 0; } scenario 2: top header 100% width , 50px height. left navigation bar 200px width , dynamic height fill screen. a container on right of nav bar , under header dynamic width , height fill screen. .container{ position: absolute; top: 50px; bottom: 0; left: 200px; right: 0; } this work, know not best way implement this. suggestions? many thx! you have add height:100% html , body tag. use calc() css function height , width properties result. refer snippet both scenarios . working. html, body{ height:100%;} header{ width:100%; height:50px;background:#777;} .nav{ height: calc( 100% - 50px ); width:200px; float:left; background:#888;} .container{ color:#fff; float:left; width:c

javascript - Json jQuery and php doesn't process value's correct -

i have : html + jquery + ajax post , php file process form values , returning error(true or false) , message html markups. my javascript code: $(document).ready(function() { var form = $('#form'); // contact form var submit = $('#submit'); // submit button var alert = $('.alert'); // alert div show alert message // form submit event form.on('submit', function(e) { e.preventdefault(); // prevent default form submit $.ajax({ url: 'contact.php', // form action url type: 'post', // form submit method get/post datatype: 'json', // request type html/json/xml data: form.serialize(), // serialize form data beforesend: function() { alert.fadeout(); submit.html('sending....'); // change submit button text }, success: function(result) { if(result.error){ /* on error stuff */ alert(result.html).fadein(); }else{

javascript - How to create a query in Mongoose/Mongodb to obtain this json? -

i'm trying obtain object mongodb, counting os per month: {january: {android: 30, ios: 10, winphone: 5}, february: {android: 4, ios: 40}, etc}. and here mongoose schema: var myschema = new schema({ date: {type: date, default: date.now}, os: string }); can give me idea? there way create single query return me entire object or should build piece piece, unifying multiple queries? thank you! you're better off using output structure that's more natural mongodb keys static , values contain data. can use aggregation pipeline as: mymodel.aggregate([ // group docs month & os {$group: {_id: {month: {$month: '$date'}, os: '$os'}, count: {$sum: 1}}}, // group again month {$group: {_id: '$_id.month', counts: {$push: {os: '$_id.os', count: '$count'}}}}, // rename _id month {$project: {month: '$_id', counts: 1, _id: 0}} ], callback); which generates output like: { "resul

sql server - Why are my variables do not change their values? -

i'm writting big procedure in t-sql dynamic elements. make short post important codelines. declare.... begin while @start <= @rowcount begin print @start print @rowcount set @sqlval = 'select @zwischen1 = @currentcolumn_val1 z_skm id = @startid'; set @parmdefinitionval = n'@currentcolumn_val1 nvarchar(500), @startid int, @zwischen1 nvarchar(50) output'; exec sp_executesql @sqlval, @parmdefinitionval, @currentcolumn_val1 = @currentcolumn_val, @startid = @start, @zwischen1 = @currentval output; print @currentval set @sqlkey ='select @zwischen2 = @currentcolumn_key1 z_skm id = @startid'; set @parmdefinitionkey = n'@currentcolumn_key1 nvarchar(500), @startid int, @zwischen2 nvarchar(50) output'; exec sp_executesql @

wordpress - Migration done in WP, but now getting '300 Multiple Choices' error -

i have done migration subdomain root when try link others pages site, receive following message: multiple choices the document name requested (/maquetacion.php) not found on server. however, found documents names similar 1 requested. available documents: /maquetacion.html?page_id=56 (common basename) please consider informing owner of referring page broken link. my index showed fine , along others pages in following url: wp-content/themes/website/index.php i have changed wordpress url , site url same. the links index this: <a href="maquetacion.php?page_id=56"></a> from subdomain, site runs rightly. idea? try resetting custom permalinks default setting via settings -> permalinks. if works, review using_permalinks before setting custom permalink structure again.

ios8 - iOS Push Notifications with Moon APNS - works on local, but not on server side -

so, using moon apns ios push notifications , worked fine until recent. firstly, apple no longer supports ssl , changed tls instead. second thing (and strange one), if invoke webservice on local computer send push notification, works fine. but, when publish code our testing server , push notifications not delivered phone, code same! one other thing, after sendtoapple method called, ok status code , notification doesn't come. any ideas? i'm posting our solution, maybe has same problem. first of all, moon apns uses ssl encryption , deprecated apple. should alter moon apns library use tls instead. second thing is, make sure compile library newtonsoft json library version 6.0.0.0 . our problem was, used older version of json library (i think version 4.x.x.x) , somewhere deep in library exception occurred , returned 0 in sendtoapple. ironically, apple uses 0 status ok , tricky found out problem lies.

algorithm - OpenCL matrix reduction in two stages -

i have 2d array of m x n entries. a0 a1 a2 a3 a4 a5 ... b0 b1 b2 b3 b4 b5 ... bn ... i want reduce array single value in 2 stages. stage 1: calculate function values each item in row, , sum them weights. a = w0*f(a0) + w1*f(a1) + w2*f(a2) + ... b = w0*f(b0) + w1*f(b1) + w2*f(b2) + ... stage 2: compare results input vector , calculate chi-square value. chi_sq = (a - x)^2/sx^2 + (b - y)^2/sy^2 + ... i trying in parallel using opencl. however, have hard time figuring out best strategy kind of algorithm. example, there many examples out there loop on matrix rows, , many sources state should not this. kind outline how problem can solved optimally?

uibinder - How to call method of @UiField field in GWT -

here classes public class personview extends composite{ private person person; @uifield firstnameview firstnameview; @uifield lastnameview lastnameview; public personview(person person) { setdata(person); } public void setdata(person person) { firstnameview.setdata(person.getfirstname()); lastnameview.setdata(person.getlastname()); } } public class firstnameview extends composite{ private firstname firstname; @uifield textbox firstnametextbox; public firstnameview() { } public void setdata(firstname firstname) { firstnametextbox.setvalue(firstname.getfirstname()); } } public class lastnameview extends composite{ private lastname lastname; @uifield textbox lastnametextbox; public lastnameview() { } public void setdata(lastname lastname) { lastnametextbox.setvalue(lastname.getlastn

haskell - How to profile libraries? -

is there hidden option put cost centres in libraries? have set profiling this: cabal: ghc-prof-options: -o2 -threaded -fexcess-precision -fprof-auto

html - Navigation bar not centering -

html : <nav> <ul> <li><a href="index">home</a></li> <li><a href="history">history</a></li> <li><a href="appointments">appointments</a></li> <li><a href="contactus">contact us</a></li> </ul> </nav> css : nav { position: relative; margin: auto; padding: 0; list-style: none; width: 100%; display: center;} nav ul li { display: inline; } nav ul li { display: inline-block; text-decoration: none; padding: 5px 0; width: 100px; background: #cc3399; color: #eee; float: left; text-align: center; border-left: 1px solid #fff; } nav ul li a:hover { background: #a2b3a1; color: #000 } basically, i've managed make navigation bar, fits specifications. however, it's not centered, it's in position vertically, horizontally it's way left , no

Jenkins failed to deploy ear to websphere 6.1 using websphere deployer plugin -

i trying deploy ear file websphere. throwing below error.. can me in this...? [echo] creating war... @ 11-19-2014 04:21pm [war] building war: f:\workspace\pec_admin\buildarchive\providereconnect.war build-ear: [echo] copy meta-inf prepare ear... [echo] creating ear... @ 11-19-2014 04:21pm [ear] building ear: f:\workspace\pec_admin\buildarchive\providereconnect.ear build successful total time: 1 minute 38 seconds connecting ibm websphere application server... error deploying ibm websphere application server: java.io.ioexception: expecting ant glob pattern, saw 'f:\workspace\pec_admin\buildarchive\providereconnect.ear'. see http://ant.apache.org/manual/types/fileset.html syntax @ hudson.filepath.glob(filepath.java:1517) @ hudson.filepath.access$700(filepath.java:168) @ hudson.filepath$26.invoke(filepath.java:1498) @ hudson.filepath$26.invoke(filepath.java:1495) @ hudson.filepath.act(filepath.java:865) @ hudson.filepath.act(filepath.java:838)

sql server - Working days SQL query -

i have problem can't head around. i have table of events , table of users. events chargeable , not. want establish number chargeable days per week month , year every user. here data... id fromdate todate ischargeable username 1 2014-11-03 2014-11-04 y auser 2 2014-11-04 2014-11-06 y auser 3 2014-11-07 2014-11-07 y auser and i've written basic query calculate difference between , dates , sum them adding 1 total todate counts full day. select distinct fromdate, todate, ischargeable,username, datediff(day, fromdate, todate) + 1) 'count1' dbo.vdiary group fromdate, todate, ischargeable,username this results in... fromdate todate ischargeable username count1 2014-11-03 2014-11-04 y auser 2 2014-11-04 2014-11-06 y auser 3 2014-11-07 2014-11-07 y auser 1 which incorrec

c# 3.0 - Remove all commas from a string in C# 3 -

i have string type variable a="a,b,c,d"; i want remove commas , new value abcd .i tried a.replace(",","") not working.i using c# 3.0 try instead a = a.replace("," , ""); edit your code correct far using replace() function goes. missing replace() not modify orignal string, returns new (updated) string should save.

vb.net - Outputting multiple variables defined in a method -

i have series of basic calculations on form triggered form load event: dim somevariablea integer dim somevariableb integer dim somevariablex integer = 1 dim somevariabley integer = 2 somevariablea = somevariablex + somevariabley somevariableb = somevariablex * somevariabley i require exact calculations separate form. rather pasting same again, there means can place calculation in method both forms can call upon? public function somefunction() ' above calculations placed here instead. end function private sub somesub() ' call calculations. somefunction() ' ...now output , use variables function. textbox1.text = somevariablea textbox2.text = somevariableb end sub ultimately, i'm expecting behaves php's include function. you running issue of scope . variable declared determines availability. know how make variables visible methods in form: public class form1 private vara string private var2 integer these ava

spring integration - Dispatcher has no subscribers error for ftp -

i have file dropped @ ftp location should picked ftp-inbound-adapter. file saved local-directory. local-directory in turn polled spring file-inbound-adapter. filenamegenerator bean used in file-inbound-adapter , decides destination dynamically. have posted question file in local-directory not being deleted. problem facing. entire configuration <util:properties id="someid" location="classpath:config/config.properties"/> <mvc:annotation-driven /> <context:component-scan base-package="com.dms" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <context

c# - Background worker to copy directory -

in windows form application, directories copied on user request. copying these directories running on ui thread result, not able see progress of process. currently copy function trigger following code. private void button5_click(object sender, eventargs e) { string[] str = combobox2.text.split(' '); string username = str[2].replace("[", "").replace("]", ""); label3.text = combobox3.text; dialogresult result = messagebox.show("do want copy " + combobox3.text + " mozilla profile " + username + " selected servers?", "confirmation", messageboxbuttons.yesnocancel); if (result == dialogresult.yes) { if (mycheck.checked == true) { string path = getpath(combobox3.text); try { string source = path +

regex - Oracle declare select into update statement does not work -

i had issue due database charset special characters weird codes assigned them, getting select ascii(substr(declinereasondesc, 30,1)) declinereason t declinereasonid = 7; got code (49827) £ in db charset. tried update records in database. problem getting data not saved db or selecting into value varchar2(6); somehow changes , not match regexp_replace any-more. it did error when tried using varchar2(1) should value, hint. declare c varchar2(6); begin select ascii(substr(declinereasondesc, 30,1)) c declinereason t declinereasonid = 7; begin update declinereason set declinereasondesc = regexp_replace(declinereasondesc, '(.+)('||c||')(\d+)', '\1\3 (gbp)'); commit; end; end; / commit; update: tried declare c number; no errors didn't update values ether this 1 caused me being stupid - forgot wrap c in chr(c) . declare c number; begin select ascii(substr(declinereasondesc, 30,1)) c declinereason t declinereasonid = 7; begin

How can I load external javascript files using AJAX and know that loading has failed? -

i have written function takes array of url strings first argument , tries use them load external script. allows me link multiple sources in case 1 mirror down. function loadscript(scripts, name, index) { //convert single string array - not effective easy if(!(scripts instanceof array)) scripts = [scripts]; //use first script src if no name defined if(name==null) { name = scripts[0]; } //default index 0 if(index==null) index = 0; //in case wrong index provided if(index>=scripts.length) throw new error("aray index out of bounds."); //create request var req = new xmlhttprequest(); req.open("get", scripts[index]); //execute response text on success req.onload = function() { scriptfromstring(this.responsetext); } //iterate on error req.onerror = function() { if(index+1<scripts.length) { loadscript(scripts, name, index); } else { throw new error("all sources failed '"

runtime error - Excel 2010 VBA: Invalid procedure call when adding data field to pivot table -

i want create multiple pivot tables encapsulating complexity functions , procedures (i did manage create pivots vba, 1 module each pivot, meaning lots of repetitive code...) i managed create procedures , functions create pivot, add filter, , row field. when comes adding data field, invalid procedure call; strange thing error when use variables pass info: looking @ line prodicung error, first line works fine, whereas cannot second line running (the variables contain correct values): pivotname.adddatafield pivotname.pivotfields("sdid"), "sd id number", xlcount 'works fine pivotname.adddatafield pivotname.pivotfields(fieldname), fielddescription, calcmethod 'produces invalid procedure call error as running out of ideas, highly appreciated! thank much, alexander the reason error due calcmethod being declared earlier in code string . the .adddatafield method accepts following parameters: .adddatafield(field, caption, function) th

doctrine2 - PHP Zend2 bjyauthorize doctrine Where set default role if no identity is given -

i'm pretty new zend 2, doctrine , stuff in project implement bjyauthorize module zend 2 via doctrine. have done stuff - implement , configured except default role, if no identitiy given (new user visting, or after logout example). role , user classes blueprints bjyauthorize this identity provider class defined in bjyauthorize.global.php 'identity_provider' => 'application\provider\identity\identityprovider', code: namespace application\provider\identity; use bjyauthorize\provider\identity\providerinterface; use zend\authentication\authenticationservice; class identityprovider implements providerinterface { // public function getdefaultrole() // { // $atest = "test"; // return new debug(); // } public function getidentityroles() { $oidentity = $this->getidentity(); $aroles = []; if(!empty($oidentity)) { $aroles = $oidentity->getroles(); }

how to read a long value from standard input in java? -

i using util.scanner read input user. don't understand how read long datatype value. scanner scr=new scanner(system.in); long l=scr.nextint(); i unable read 64-bit data using above code — gives me input mismatch exception. use nextlong method : long l=scr.nextlong();

Android windowIsTranslucent locks orientation to portrait -

i have activity launched using: <item name="android:windowistranslucent">true</item> i not understand why on handset devices orientation locked portrait , on tablet not. when remove flag orientation available both on handsets , tablets. answer: https://stackoverflow.com/a/3821680/2746924

javascript - AngularJS is not validating my form -

i know angular pretty well, use everyday, apparently, i'm having 1 of days.. i'm missing hideously obvious, why aren't seeing testform.testfield.$invalid & testform.testfield.$dirty etc??? var myapp = angular.module('myapp',[]); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp"> <form name="testform"> <input type="text" name="testfield" ng-model="testfield" required="required" /> {{testform | json}} {{testfield}} </form> </div> if in angular source, conversion json says: properties leading $ characters stripped since angular uses notation internally. unfortunately documentation json filter doesn't mention that. see https://github.com/gaborcs/angular.js/blob/master/src/angular.js lines 930-931.

php - CodeIgniter not fetching entire field data -

i'm using codeigniter contact old mssql 6.5 database via unixodbc , freetds. connection works fine , can run queries, problem id doesn't return entire field data. ex. ["frame9val"]=> string(3) "13" -> should show 135 ["frame1bval"]=> string(3) "2�" -> should show 255 any idea why happening , how fix it? made test-php pdo , works fine. $this->db->select('tblscore.sessionnum, tblscore.gamenum, tblscore.laneid, tblscore.playercnt, tblplayerscore.bowlername, tblframescore.frame1val, tblframescore.frame2val, tblframescore.frame3val, tblframescore.frame4val, tblframescore.frame5val, tblframescore.frame6val, tblframescore.frame7val,