Posts

c++ - (char *) (msg +1) where does this +1 takes us to? -

i seeing code, in have statement (char *)(emsg+1) given, i guess (char *) emsg might have been string, + 1 here? emsg pointer type (e.g. int ). emsg + 1 increments pointer 1, i.e. points initial address + sizeof(int) . then, (char*) (emsg + 1) cast, i.e. end result casted char* pointer, end pointer-to-char points initial address + sizeof(int) . in general, char* pointers characters, i.e. c -like 0 terminated strings, not case. convert pointer char* when want "extract" smallest unit of addressable memory, on machines char* pointer underlying type of 1 byte ( char ).

plsql - Oracle: Deferring a constraint in a begin/end block? -

how defer constraint inside begin/end block? this works: sql> set constraint t_pk deferred; constraint set. but identical statement fails in begin/end block: sql> begin 2 set constraint t_pk deferred; 3 end; 4 / set constraint t_pk deferred; * error @ line 2: ora-06550: line 2, column 5: pl/sql: ora-00922: missing or invalid option ora-06550: line 2, column 1: pl/sql: sql statement ignored you need use execute immediate : begin execute immediate 'set constraint t_pk deferred'; end;

JQuery Ajax function error when indeed there is a success -

my code calls error function, when hits action url supposed to. here jquery ajax code: function contactdialog(action, controller) { var url = '/' + action + '/' + controller; $("#contactdialog").dialog({ autoopen: true, hide: "fade", show: "bounce", height: $(window).height() / 2, width: $(window).width() / 2, title: "send email", buttons: [{ text: "send", click: function () { $.ajax({ url: url, data: $("form").serialize(), context: this, contenttype: 'application/html; charset=utf-8', datatype: "json", //xml, json, script , html success: function () { $(this).dialog("close"); sendconfirmmessage('msgsent'); ...

c++ - Template template parameters - extension to std::array -

i have question template template parameters: let's consider following class: template<typename t, template<class, class=std::allocator<t> > class underlyingcontainertype = std::vector> class mycontainer { public: t value1; t value2; underlyingcontainertype<t> container; mycontainer() {} /* methods implementation goes here */ }; in example, mycontainer container chat uses underlying stl-compatible container whatever stuff. declaring underlying container type template template parameters, instead of regular template argument, allows handy usage of class mycontainer, such as: mycontainer<int> mcv; //implicitly using vector mycontainer<int, std::list> mcl; //no need write std::list<int> //template template parameters now, while work of stl-container, such std::vector, std::deque, std::list, , forth, not work, example, std::array provided in c++11. the reason ...

alignment - How to right align my answers in python? -

how right align answers when input first, second , last number, sum , average. #create function def list_sum(num_list): #calculate , print out sum of numbers the_sum = 0 in num_list: the_sum = the_sum + return the_sum #accept 3 numbers , store them in variables input_1 = float(raw_input("input number: ")) input_2 = float(raw_input("input second number: ")) input_3 = float(raw_input("input last number: ")) #take list of inputs list_of_inputs = [input_1, input_2, input_3] #calculate , print out sum of numbers sum_of_input = list_sum(list_of_inputs) print("the sum: {:.2f}".format(sum_of_input)) #calculate , print out average of numbers the_average = (sum_of_input)/(len(list_of_inputs)) print("the average: {:.2f}".format(the_average)) #calculate , print out percent of total each number represents input_in_list in list_of_inputs: percent_total = input_in_list/sum_of_input print("the percen...

php - Should I keep a similar tests for Unit Testing and DBUnit testing in a Data Mapper? -

i've been practicing , reading test driven development. i've been doing far since of straightforward have questions test classes such 1 below. public function testpersonenrollmentdateisset() { //for sake of simplicity i've abstracted pdo/connection mocking $pdo = $this->getpdomock(); $pdostatement = $this->getpdostatementmock(); $pdo->method('prepare')->willreturn($pdostatement); $pdostatement->method('fetch')->willreturn('2000-01-01'); $accountmapper = $this->mapperfactory->build( 'accountmapper', array($pdo) ); $person = $this->entityfactory->build('person'); $account = $this->entityfactory->build('account'); $person->setaccount($account); $accountmapper->getaccountenrollmentdate($person); $this->assertequals( '2001-01-01', ...

google maps api 3 - how to get cityname from address php, googlemaps -

i need find cityname address, have take input(single textbox streetname, cityname,country) ex: skyline blvd 35, california, usa. $str = "skyline blvd 35, munchen, germany"; result: munchen what thought first find lat , lng , reverse geo cityname. lat n long: developers.google.com/maps/documentation/geocoding/?csw=1#geocoding reverse geo:developers.google.com/maps/documentation/geocoding/?csw=1#reversegeocoding i wonderring if there way of getting cityname may string itself.. skyline blvd35, munchen, germany. $x = file_get_contents( "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . urlencode( "skyline blvd 35, california, usa" )); $o = json_decode( $x ); foreach ( $o->results[0]->address_components $component ) { if ( $component->types[0] == 'administrative_area_level_1' ) print $component->long_name; }