Posts

PHP - Calling functions with multiple variables -

this seems basic question know i've not been able find answer. let's assume basic function: function basicfunction ( $var1, $var2 = 1, $var3 = 2, $var4 = 5 ) { // stuff // return } now let's assume want call function following variables: $var1 = 0 $var2 = 1 $var3 = 2 $var4 = 3 i can this: $someresult = basicfunction( 0, 1, 2, 3 ); $var2 , $var3 set though, how call function without having repeat value $var2 , $var3 ? php not support overloading. therefore, cannot skip them in way if don't move them right of list of arguments. a common solution set default value of different type expected (i.e. null). actual default value set within function. approach not clean , takes lines of code, if situation requires it, can go this: function basicfunction($var1, $var2 = null, $var3 = null, $var4 = null) { if ($var2 === null) { $var2 = 1; } // ...

haskell - Maybe monad usage example -

i'm trying learn haskell i'm having problem in monad usage. i imported module data.maybe . but don't know how use >>= operator. given (>>=) :: monad m => m -> (a -> m b) -> m b cannot understand how define function (a -> m b) . can provide pedagogical example? for maybe monad bind function ( >>= ) looks that: (>>=) :: maybe -> (a -> maybe b) -> maybe b so, let's define maybe a value: > let = 1 :: maybe integer and :: -> maybe b function: > let f = \x -> (x+1) f :: integer -> maybe integer now can use bind infix operator: > >>= f 2 :: maybe integer another example of a -> maybe b function be: let h :: integer -> maybe string; h = return . show . (+1) h :: integer -> maybe string so h increment integer number, convert string , make maybe value return function. > >>= h "2"

php - Call to a member function setName() on a non-object in symfony2 -

i trying edit form form existing values correctly when try put new data in fields , submit form error of call member function setname() on non-object my controller method public function editaction(request $request){ $request = request::createfromglobals(); $group_id = $request->query->get('id'); $em = $this->getdoctrine()->getentitymanager(); $patent_group = $em->getrepository('munichinnovationgroupbundle:pmpatentgroups')->find($group_id); //echo '<pre>'; //print_r($patent_group); //echo '</pre>'; $form = $this->createform(new patentgrouptype(), $patent_group); if ($request->getmethod() == 'post') { $form->bindrequest($request); $name = $form["name"]->getdata(); $description = $form["description"]->getdata(); $patent_group->setname($name); $patent_group->setdescription($description); $em-...

Cookie not getting set for index.php page in Safari 5.1.7 -

i have following script add cookie page visited colorbox: if (document.cookie.indexof('visited=true') === -1) { var expires = new date(); expires.setdate(expires.getdate()+1000); document.cookie = "visited=true; path=/index.php; expires="+expires.toutcstring(); $.colorbox({href:'files/welcome.html', width:"45%", speed:1500}); } this sets cookie in firefox , chrome page visited not in safari (5.1.7). similar script sets cookie page on site, setting path=/mixups/june_2012/ works fine in safari. does know why happening, , if there fix? thanks, nick

anchor - jQuery selector with specific attribute -

i've got code: $('a').click( function() { $("#change_flash").css("display", "block"); $("#my_flash").css("display", "none"); }); but 1 works anchor elements. influence script anchors elements contains rel="lightbox" attribute. how can achieve it? $('a[rel="lightbox"]').click( function() { $("#change_flash").css("display", "block"); $("#my_flash").css("display", "none"); });

xamarin.android - monodroid wcf call -

Image
i'm having difficulties accessing wcf service. service running in same solution monodroid app , hosted visual studio. configured basichttp. reference adds ok @ runtime when call 1 simple test method, ; system.net.webexception it's simple web service public class service1 : system.web.services.webservice { [webmethod] public string helloworld() { return "hello world"; } } and here call button.click += delegate { localhost.service1 se = new localhost.service1(); button.text= se.helloworld(); }; and error snapshot in attachment i agree need add more information. however, responded question sometime ago , doing wcf stuff , it's working great me. using soap in shared mono library wp 7 , android this might out. one other thing thought of. have internet option in network manifest selected shown here: http://docs.xamarin.com/@api/deki/files/1026/=requiredpermissionsvs.png...

Is there a faster way to sum up an arithmetic sequence of numbers in Python? -

total = 0 in range(0, upper bound): total += sorry if basic have lot of these , they're taking more room comfortable. total = sum(range(upper)) or total = upper * (upper - 1) / 2 the first 1 python, second 1 gauss. edit: when not starting @ zero: total = sum(range(lower, upper)) or, again according gauss, same upper , substract same lower : total = upper * (upper - 1) / 2 - lower * (lower - 1) / 2 if on python 2.x, replace range xrange .