Posts

javascript - Unset object property -

i have provider: advicelist.provider('$advicelist',function(){ this.$get = function ($rootscope,$document,$compile,$http,$purr){ function advicelist(){ $http.post('../sys/core/fetchtreatments.php').success(function(data,status){ this.treatments = data; console.log(this.treatments); // correct object }); this.advicecategories = [ // available in controller ]; } return{ advicelist: function(){ return new advicelist(); } } } }); further, have controller: advicelist.controller('advicelistctrl',function($scope,$advicelist){ var adv = $advicelist.advicelist(); $scope.treatments = adv.treatments; // undefined }); why it, controller's $scope.treatments stays undefined, this.treatments inside provider however, filled correctly? also, advicecategories available in contr...

java - How to create request scoped web service port? -

i have spring mvc based web application calls web service. web service requires http based authentication every call.i hold web service proxy configuration in applicationcontext.xml: <beans... <bean id="paymentwebservice" class="org.springframework.remoting.jaxws.jaxwsportproxyfactorybean"> <property name="customproperties"> <ref local="jaxwscustomproperties"/> </property> <property name="serviceinterface" value="com.azercell.paymentgateway.client.paymentgatewaywebservice"/> <property name="wsdldocumenturl" value="#{config.wsdldocumenturl}"/> <property name="namespaceuri" value="http://webservice.paymentgateway.azercell.com/"/> <property name="servicename" value="paymentgatewaywebserviceimplservice"/> <property name="portname" value="paym...

php - Get X first/last WORDS from string -

ok, need... example input : $str = "well, guess know # : & ball"; example output : firstwords($str,5) should return array("well","i","guess","i","know") lastwords($str,5) should return array("is","it","is","a","ball") i've tried custom regexes , str_word_count , still feel if i'm missing something. any ideas? all need $str = "well, guess know # : & ball"; $words = str_word_count($str, 1); $firstwords = array_slice($words, 0,5); $lastwords = array_slice($words, -5,5); print_r($firstwords); print_r($lastwords); output array ( [0] => [1] => [2] => guess [3] => [4] => know ) array ( [0] => [1] => [2] => [3] => [4] => ball )

c# - How does the following LINQ statement work? -

how following linq statement work? here code: var list = new list<int>{1,2,4,5,6}; var = list.where(m => m%2 == 0); list.add(8); foreach (var in even) { console.writeline(i); } output: 2, 4, 6, 8 why not 2, 4, 6 ? the output 2,4,6,8 because of deferred execution . the query executed when query variable iterated over, not when query variable created. called deferred execution. -- suprotim agarwal, "deferred vs immediate query execution in linq" there execution called immediate query execution , useful caching query results. suprotim agarwal again: to force immediate execution of query not produce singleton value, can call tolist(), todictionary(), toarray(), count(), average() or max() method on query or query variable. these called conversion operators allow make copy/snapshot of result , access many times want, without need re-execute query. if want output 2,4,6 , use .tolist() : var list = new list<int...

c# - MVC, I get it, but separating out the model for repository functions and maybe even business logic... Best practice? -

Image
c# asp .net mvc 4.0 i understand mvc pattern, when comes down model: public class user { int id { get; set } int name { get; set; } } i see benefit dividing business logic repository ( data fetchers ). like: public class userrepository { ienumerablelist<user> getallusers() { ienumerablelist<product> users = //linq or entity; return ienumerablelist<product> users; } int getscorebyuserid( id ) { int score = //linq or entity; return score; } } would business logic go user class like: public class user { public int id { get; set } public int name { get; set; } public bool hasdiscount( int id ) { if( getscorebyuserid( id ) > 5 ) return true; return false; } } does have decent example. it's not easy 1 2 3 find such explicit example me. does above code seem okay? should repository extend user or should separate class.....

forms - Better dropdown with bootstrap -

Image
i try use dropdowns of bootstrap, it's work problem esthetic. : http://twitter.github.io/bootstrap/javascript.html#dropdowns i have code : <div class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">colléctivités <b class="caret"></b></a> <ul class="dropdown-menu" role="menu" aria-labelledby="dlabel"> <?php foreach ($collectivite $key => $value) { echo '<form method="post" action="wbx.php"><li><button type="submit" class="btn" style="margin:0px;" name="cookie" value='.$value.'>'.$value.'</button> </li></form>'; } ?> </ul> </div> without php : <div class="dropdown"> <a class="dropdown-toggle" data-toggle...

php - Multipart response in Laravel 4 -

does laravel 4 support multipart response? need output , process, parse kind of data. json combined base64 image blobs. just image there route handling request "something.com/api/v1/get-all" action in controller should respond multipart. whats best practice in laravel framework? content-type: multipart/form-data; boundary=.............................103832778631715 --.............................103832778631715 content-disposition: form-data; name="__json_data__"; content-type: application/json; { "item": { "uuid": "12345-523462362-252636", "title": "title" } } .............................103832778631715 content-disposition: form-data; name="imagefile"; filename="someimage.jpg" content-type: application/octet-stream [[[base64 encoded contents of file]]] .............................103832778631715-- you want mulipart form, don't you? echo form::o...