Search Results

Search found 9058 results on 363 pages for 'length'.

Page 22/363 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Returning new object, overwrite the existing one in Java

    - by lupin
    Note: This is an assignment. Hi, Ok I have this method that will create a supposedly union of 2 sets. i mport java.io.*; class Set { public int numberOfElements; public String[] setElements; public int maxNumberOfElements; // constructor for our Set class public Set(int numberOfE, int setE, int maxNumberOfE) { this.numberOfElements = numberOfE; this.setElements = new String[setE]; this.maxNumberOfElements = maxNumberOfE; } // Helper method to shorten/remove element of array since we're using basic array instead of ArrayList or HashSet from collection interface :( static String[] removeAt(int k, String[] arr) { final int L = arr.length; String[] ret = new String[L - 1]; System.arraycopy(arr, 0, ret, 0, k); System.arraycopy(arr, k + 1, ret, k, L - k - 1); return ret; } int findElement(String element) { int retval = 0; for ( int i = 0; i < setElements.length; i++) { if ( setElements[i] != null && setElements[i].equals(element) ) { return retval = i; } retval = -1; } return retval; } void add(String newValue) { int elem = findElement(newValue); if( numberOfElements < maxNumberOfElements && elem == -1 ) { setElements[numberOfElements] = newValue; numberOfElements++; } } int getLength() { if ( setElements != null ) { return setElements.length; } else { return 0; } } String[] emptySet() { setElements = new String[0]; return setElements; } Boolean isFull() { Boolean True = new Boolean(true); Boolean False = new Boolean(false); if ( setElements.length == maxNumberOfElements ){ return True; } else { return False; } } Boolean isEmpty() { Boolean True = new Boolean(true); Boolean False = new Boolean(false); if ( setElements.length == 0 ) { return True; } else { return False; } } void remove(String newValue) { for ( int i = 0; i < setElements.length; i++) { if ( setElements[i] != null && setElements[i].equals(newValue) ) { setElements = removeAt(i,setElements); } } } int isAMember(String element) { int retval = -1; for ( int i = 0; i < setElements.length; i++ ) { if (setElements[i] != null && setElements[i].equals(element)) { return retval = i; } } return retval; } void printSet() { for ( int i = 0; i < setElements.length; i++) { if (setElements[i] != null) { System.out.println("Member elements on index: "+ i +" " + setElements[i]); } } } String[] getMember() { String[] tempArray = new String[setElements.length]; for ( int i = 0; i < setElements.length; i++) { if(setElements[i] != null) { tempArray[i] = setElements[i]; } } return tempArray; } Set union(Set x, Set y) { String[] newXtemparray = new String[x.getLength()]; String[] newYtemparray = new String[y.getLength()]; int len = newYtemparray.length + newXtemparray.length; Set temp = new Set(0,len,len); newXtemparray = x.getMember(); newYtemparray = x.getMember(); for(int i = 0; i < newYtemparray.length; i++) { temp.add(newYtemparray[i]); } for(int j = 0; j < newXtemparray.length; j++) { temp.add(newXtemparray[j]); } return temp; } Set difference(Set x, Set y) { String[] newXtemparray = new String[x.getLength()]; String[] newYtemparray = new String[y.getLength()]; int len = newYtemparray.length + newXtemparray.length; Set temp = new Set(0,len,len); newXtemparray = x.getMember(); newYtemparray = x.getMember(); for(int i = 0; i < newXtemparray.length; i++) { temp.add(newYtemparray[i]); } for(int j = 0; j < newYtemparray.length; j++) { int retval = temp.findElement(newYtemparray[j]); if( retval != -1 ) { temp.remove(newYtemparray[j]); } } return temp; } } // This is the SetDemo class that will make use of our Set class class SetDemo { public static void main(String[] args) { //get input from keyboard BufferedReader keyboard; InputStreamReader reader; String temp = ""; reader = new InputStreamReader(System.in); keyboard = new BufferedReader(reader); try { System.out.println("Enter string element to be added" ); temp = keyboard.readLine( ); System.out.println("You entered " + temp ); } catch (IOException IOerr) { System.out.println("There was an error during input"); } /* ************************************************************************** * Test cases for our new created Set class. * ************************************************************************** */ Set setA = new Set(0,10,10); setA.add(temp); setA.add("b"); setA.add("b"); setA.add("hello"); setA.add("world"); setA.add("six"); setA.add("seven"); setA.add("b"); int size = setA.getLength(); System.out.println("Set size is: " + size ); Boolean isempty = setA.isEmpty(); System.out.println("Set is empty? " + isempty ); int ismember = setA.isAMember("sixb"); System.out.println("Element sixb is member of setA? " + ismember ); Boolean output = setA.isFull(); System.out.println("Set is full? " + output ); //setA.printSet(); int index = setA.findElement("world"); System.out.println("Element b located on index: " + index ); setA.remove("b"); //setA.emptySet(); int resize = setA.getLength(); System.out.println("Set size is: " + resize ); //setA.printSet(); Set setB = new Set(0,10,10); setB.add("b"); setB.add("z"); setB.add("x"); setB.add("y"); Set setC = setA.union(setB,setA); System.out.println("Elements of setA"); setA.printSet(); System.out.println("Union of setA and setB"); setC.printSet(); } } The union method works a sense that somehow I can call another method on it but it doesn't do the job, i supposedly would create and union of all elements of setA and setB but it only return element of setB. Sample output follows: java SetDemo Enter string element to be added hello You entered hello Set size is: 10 Set is empty? false Element sixb is member of setA? -1 Set is full? true Element b located on index: 2 Set size is: 9 Elements of setA Member elements on index: 0 hello Member elements on index: 1 world Member elements on index: 2 six Member elements on index: 3 seven Union of setA and setB Member elements on index: 0 b Member elements on index: 1 z Member elements on index: 2 x Member elements on index: 3 y thanks, lupin

    Read the article

  • Display all the options if nothing is selected

    - by Levani
    I have four level connected dropdown boxes. I can choose something from second dropdown only after I select something from the first one. The third dropdown is also depended on second one and so on. I need to make selection available in second, third and fourth dropdown, even if there isn't selected anything in previous dropdown, but if the selection is made behave as it behaves now. Am I clear? Here is the code: <table width="100%" border="0" cellspacing="1" cellpadding="4"> <!-- *********************** Countries *********************** --> <tr> <td style="width:150px"><?php if($eaconf->ea_loc_srchtype==0) echo "<b>".JText::_('EA_SRCH_STEP')."</b> 1: ";?><?php echo JText::_('EA_OBJ_COUNTRY'); ?></td> <td > <?php $countrylist[] = JHTML::_('select.option', 'no', JText::_('EA_NOT_SELECTED')); $x=0; foreach($countries as $c){ $countrylist[] = JHTML::_('select.option', $c ,JText::_($countrynames[$x])); $x++; } if($eaconf->ea_loc_srchtype==0){ $countrys['src_country'] = JHTML::_('select.genericlist', $countrylist,'src_country',' class="inputbox" style="width:140px" onChange="setStates(this.selectedIndex-1)"', 'value', 'text','0' ); }else{ $countrys['src_country'] = JHTML::_('select.genericlist', $countrylist,'src_country',' class="inputbox" style="width:140px" ', 'value', 'text','0' ); } ?> <?php echo $countrys['src_country'];?> </td> </tr> <!-- *********************** States *********************** --> <tr> <td ><?php if($eaconf->ea_loc_srchtype==0) echo "<b>".JText::_('EA_SRCH_STEP')."</b> 2: ";?><?php echo JText::_('EA_OBJ_STATE'); ?></td> <td > <?php $statelist[] = JHTML::_('select.option', 'no', JText::_('EA_NOT_SELECTED')); foreach($stateslist as $s){ $statelist[] = JHTML::_('select.option', $s ,JText::_($s)); } if($eaconf->ea_loc_srchtype==0){ $thestates['src_state'] = JHTML::_('select.genericlist', $statelist,'src_state',' class="inputbox" style="width:140px" onChange="setDistricts(this.selectedIndex-1)"', 'value', 'text','0' ); }else{ $thestates['src_state'] = JHTML::_('select.genericlist', $statelist,'src_state',' class="inputbox" style="width:140px" ', 'value', 'text','0' ); } ?> <?php echo $thestates['src_state'];?> </td> </tr> <!-- *********************** Districts ******************** --> <tr> <td > <?php if($eaconf->ea_loc_srchtype==0) echo "<b>".JText::_('EA_SRCH_STEP')."</b> 3: ";?><?php echo JText::_('EA_OBJ_DISTRICT'); ?> </td> <td > <?php $districtlist[] = JHTML::_('select.option', 'no',JText::_('EA_NOT_SELECTED')); foreach($districtslist as $dist){ $districtlist[] = JHTML::_('select.option', $dist ,JText::_($dist)); } if($eaconf->ea_loc_srchtype==0){ $thedistrict['src_district'] = JHTML::_('select.genericlist', $districtlist,'src_district',' class="inputbox" style="width:140px" onChange="setTowns(this.selectedIndex-1)"', 'value', 'text','0' ); }else{ $thedistrict['src_district'] = JHTML::_('select.genericlist', $districtlist,'src_district',' class="inputbox" style="width:140px" ', 'value', 'text','0' ); } ?> <?php echo $thedistrict['src_district'];?> </td> </tr> <!-- *********************** Towns ************************* --> <tr> <td ><?php if($eaconf->ea_loc_srchtype==0) echo "<b>".JText::_('EA_SRCH_STEP')."</b> 4: ";?><?php echo JText::_('EA_OBJ_TOWN'); ?></td> <td > <?php $townlist[] = JHTML::_('select.option', 'no',JText::_('EA_NOT_SELECTED')); foreach($townslist as $town){ $townlist[] = JHTML::_('select.option', $town ,JText::_($town)); } if($eaconf->ea_loc_srchtype==0){ $towns['src_town'] = JHTML::_('select.genericlist', $townlist,'src_town',' class="inputbox" style="width:140px" ', 'value', 'text','0' ); }else{ $towns['src_town'] = JHTML::_('select.genericlist', $townlist,'src_town',' class="inputbox" style="width:140px" ', 'value', 'text','0' ); } ?> <?php echo $towns['src_town'];?> </td> </tr> </table> And the javascript: function setStates(scountry) { sel_state = document.easearch.elements["src_state"]; sel_town = document.easearch.elements["src_town"]; sel_district = document.easearch.elements["src_district"]; empty("src_state"); if(scountry=='no') { new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_state.options.length; sel_state.options[new_opt] = new_entry; sel_state.options[new_opt].value = "no"; sel_state.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; empty("src_district"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = "no"; sel_district.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; empty("src_town"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; } else{ new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_state.options.length; sel_state.options[new_opt] = new_entry; sel_state.options[new_opt].value = "no"; sel_state.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; for (x=0;x<States[scountry].length;x++ ){ new_entry = new Option(States[scountry][x]); new_opt = sel_state.options.length; sel_state.options[new_opt] = new_entry; sel_state.options[new_opt].value = x; sel_state.options[new_opt].text = States[scountry][x]; } empty("src_district"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = "no"; sel_district.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; empty("src_town"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; } } function setDistricts(sstate) { scountry = document.easearch.src_country.selectedIndex-1; // sstate = document.easearch.src_state.value; sel_district = document.easearch.elements["src_district"]; empty("src_district"); if(sstate=='no') { new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = "no"; sel_district.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; empty("src_town"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; } else{ new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = "no"; sel_district.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; for (x=0;x<Districts[scountry][sstate].length;x++ ){ new_entry = new Option(Districts[scountry][sstate][x]); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = x; sel_district.options[new_opt].text = Districts[scountry][sstate][x]; } empty("src_town"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; } } function setTowns(sdistrict) { scountry = document.easearch.src_country.selectedIndex-1; sstate = document.easearch.src_state.value; sel_town = document.easearch.elements["src_town"]; sel_district = document.easearch.elements["src_district"]; empty("src_town"); if(sdistrict=='no') { new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; empty("src_district"); new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_district.options.length; sel_district.options[new_opt] = new_entry; sel_district.options[new_opt].value = "no"; sel_district.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; } else{ new_entry = new Option("<?php echo JText::_('EA_NOT_SELECTED');?>"); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = "no"; sel_town.options[new_opt].text = "<?php echo JText::_('EA_NOT_SELECTED');?>"; for (x=0;x<Towns[scountry][sstate][sdistrict].length;x++ ){ new_entry = new Option(Towns[scountry][sstate][sdistrict][x]); new_opt = sel_town.options.length; sel_town.options[new_opt] = new_entry; sel_town.options[new_opt].value = x; sel_town.options[new_opt].text = Towns[scountry][sstate][sdistrict][x]; } } } function empty(field) { document.easearch.elements[field].options.length = 0; }

    Read the article

  • How do I get the length of a regex match in vim?

    - by misfo
    If I want to get the length of each match within the parentheses in the following regex, how do I do it?: ^\(\-\+\s\)\+ I'm trying to modify the width of columns in a buffer with data that is laid out as a table. Since the first two rows of the table will look like this DESIGN_ID DESIGN_YEAR SOURCE_REFERENCE ---------- ----------- ---------------- I want to use the regular expression to find the current width of each column.

    Read the article

  • sampling integers uniformly efficiently in python using numpy/scipy

    - by user248237
    I have a problem where depending on the result of a random coin flip, I have to sample a random starting position from a string. If the sampling of this random position is uniform over the string, I thought of two approaches to do it: one using multinomial from numpy.random, the other using the simple randint function of Python standard lib. I tested this as follows: from numpy import * from numpy.random import multinomial from random import randint import time def use_multinomial(length, num_points): probs = ones(length)/float(length) for n in range(num_points): result = multinomial(1, probs) def use_rand(length, num_points): for n in range(num_points): rand(1, length) def main(): length = 1700 num_points = 50000 t1 = time.time() use_multinomial(length, num_points) t2 = time.time() print "Multinomial took: %s seconds" %(t2 - t1) t1 = time.time() use_rand(length, num_points) t2 = time.time() print "Rand took: %s seconds" %(t2 - t1) if __name__ == '__main__': main() The output is: Multinomial took: 6.58072400093 seconds Rand took: 2.35189199448 seconds it seems like randint is faster, but it still seems very slow to me. Is there a vectorized way to get this to be much faster, using numpy or scipy? thanks.

    Read the article

  • identify accounts using zend-openid [HELP]

    - by tawfekov
    Hi! , i had successfully implemented simple open ID authentication with the [gmail , yahoo , myopenid, aol and many others ] exactly as stackoverflow do but i had a problem with identifying accounts for example 'openid_ns' => string 'http://specs.openid.net/auth/2.0' (length=32) 'openid_mode' => string 'id_res' (length=6) 'openid_op_endpoint' => string 'https://www.google.com/accounts/o8/ud' (length=37) 'openid_response_nonce' => string '2010-05-02T06:35:40Z9YIASispxMvKpw' (length=34) 'openid_return_to' => string 'http://dev.local/download/index/gettingback' (length=43) 'openid_assoc_handle' => string 'AOQobUf_2jrRKQ4YZoqBvq5-O9sfkkng9UFxoE9SEBlgWqJv7Sq_FYgD7rEXiLLXhnjCghvf' (length=72) 'openid_signed' => string 'op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle' (length=69) 'openid_sig' => string 'knieEHpvOc/Rxu1bkUdjeE9YbbFX3lqZDOQFxLFdau0=' (length=44) 'openid_identity' => string 'https://www.google.com/accounts/o8/id?id=AItOawk0NAa51T3xWy-oympGpxFj5CftFsmjZpY' (length=80) 'openid_claimed_id' => string 'https://www.google.com/accounts/o8/id?id=AItOawk0NAa51T3xWy-oympGpxFj5CftFsmjZpY' (length=80) i thought that openid_claimed_id or openid_identity is identical for every account but after some testing turns out the claimed id is changeable by the users them self in yahoo and randomly changing in case of gmail FYI am using zend openid with a bit modification on consumer class and i can't use SERG [Simple Refistration Extension] cuz currently it uses openid v1 specification :( i hadn't read the specification of openid so if any body know please help me to how to identify openid accounts to know if this account has signed in before or not

    Read the article

  • JavaScript String Library - Hitting a Minor Roadblock

    - by OneNerd
    Ok - am trying to create a string library that contains a handful of useful things missing from JavaScript. Here is what I have so far: ;function $__STRING__$(in_string) { /* internal functions */ this.s = in_string; this.toString = function(){return this.s;}; /******* these functions CAN be chained (they return the $__STRING__$ object) ******/ this.uppercase = function(){this.s = this.s.toUpperCase(); return this;}; this.lowercase = function(){this.s = this.s.toLowerCase(); return this;}; this.trim = function(){this.s = this.s.replace(/^\s+|\s+$/g,""); return this;}; this.ltrim = function(){this.s = this.s.replace(/^\s+/,""); return this;}; this.rtrim = function(){this.s = this.s.replace(/\s+$/,""); return this;}; this.striptags = function(){this.s = this.s.replace(/<\/?[^>]+(>|$)/g, ""); return this;}; this.escapetags = function(){this.s = this.s.replace(/</g,"<").replace(/>/g,">"); return this;}; this.unescapetags = function(){this.s = this.s.replace(/</g,"<").replace(/>/g,">"); return this;}; this.underscorize = function(){this.s = this.s.replace(/ /g,"_"); return this;}; this.dasherize = function(){this.s = this.s.replace(/ /g,"-"); return this;}; this.spacify = function(){this.s = this.s.replace(/_/g," "); return this;}; this.left = function(length){this.s = this.s.substring(length,0); return this;}; this.right = function(length){this.s = this.s.substring(this.s.length,this.s.length-length); return this;}; this.shorten = function(length){if(this.s.length<=length){return this.s;}else{this.left(this.s,length)+"..."; return this;}}; this.mid = function(start,length){return this.s.substring(start,(length+start));}; this._down = function(){return this.s;}; // breaks chain, but lets you run core js string functions /******* these functions CANNOT be chained (they do not return the $__STRING__$ object) ******/ this.contains = function(needle){if(this.s.indexOf(needle)!==-1){return true;}else{return false;}}; this.startswith = function(needle){if(this.left(this.s,needle.length)==needle){return true;}else{return false;}}; this.endswith = function(needle){if(this.right(this.s,needle.length)==needle){return true;}else{return false;};}; } function $E(in_string){return new $__STRING__$(in_string);} String.prototype._enhance = function(){return new $__STRING__$(this);}; String.prototype._up = function(){return new $__STRING__$(this);}; It works fairly well, and I can chain commands etc. I set it up so I can cast a string as an enhanced string these 2 ways: $E('some string'); 'some string'._enhance(); However, each time I want to use a built-in string method, I need to convert it back to a string first. So for now, I put in _down() and _up() methods like so: alert( $E("hello man").uppercase()._down().replace("N", "Y")._up().dasherize() ); alert( "hello man"._enhance().uppercase()._down().replace("N", "Y")._up().dasherize() ); It works fine, but what I really want to do it be able to use all of the built-in functions a string can use. I realize I can just replicate each function inside my object, but I was hoping there was a simpler way. So question is, is there an easy way to do that? Thanks -

    Read the article

  • How operator oveloading works

    - by Rasmi Ranjan Nayak
    I have below code class rectangle { ..... .....//Some code int operator+(rectangle r1) { return(r1.length+length); } }; In main fun. int main() { rectangle r1(10,20); rectangle r2(40,60); rectangle r3(30,60); int len = r1+r3; } Here if we will see in operator+(), we are doing r1.length + length. How the compiler comes to know that the 2nd length in return statement belong to object r3 not to r1 or r2? I think answer may be in main() we have writeen int len = r1+r3; If that is the case then why do we need to write in operator+(....) { r1.lenth + lenth; //Why not length + length? } Why not length + length? Bcause compiler already knows from main() that the first length belong to object r1 and 2nd to object r3.

    Read the article

  • PHP apache_request_headers() diagrees with reality (as confirmed by Firebug): why?

    - by Peter Howe
    I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest). Most of the time, this works fine. The request is sent with an X-Requested-With value of XMLHttpRequest. My PHP controller code uses apache_request_headers() to check whether an incoming request is Ajax or not and all works well. But not always. Intermittently, I'm getting a situation where the Ajax request is sent (and Firebug confirms for me that the headers on the request include an X-Requested-With of XMLHttpRequest) but apache_request_headers() is not returning that header in its list. The output from when I var_dump the apache_request_headers() is as follows (note the lack of X- 'Host' => string 'peterh.labs.example.com' (length=26) 'User-Agent' => string 'Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3' (length=105) 'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63) 'Accept-Language' => string 'en-gb,en;q=0.5' (length=14) 'Accept-Encoding' => string 'gzip,deflate' (length=12) 'Accept-Charset' => string 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' (length=30) 'Keep-Alive' => string '300' (length=3) 'Connection' => string 'keep-alive' (length=10) 'Referer' => string 'http://peterh.labs.example.com/qmail/' (length=40) 'Cookie' => string 'WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6' (length=57) 'Pragma' => string 'no-cache' (length=8) 'Cache-Control' => string 'no-cache' (length=8) But Firebug tells me: Request Headers: Host peterh.labs.example.com User-Agent Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3 Accept text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8 Accept-Language en-gb,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive X-Requested-With XMLHttpRequest Referer http://peterh.labs.example.com/qmail/ Cookie WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6 This mismatch is (apparently) intermittent when executing the same code. But I don't believe in "intermittent" when it comes to software! Help!

    Read the article

  • Inconsistent Behavior From Declared DLL Function

    - by Steven
    Why might my GetRawData declared function return a correct value when called from my VB.NET application, but return zero when called from my ASP.NET page? The code is exactly the same except for class type difference (Form / Page) and calling event handler (Form1_Load, Page_Load). Note: In the actual code, #DLL# and #RAWDATAFILE# are both absolute filenames to my DLL and raw data file respectively. Note: The DLL file was not created by Visual Studio. Form1.vb Public Class Form1 Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length) Default.aspx.vb Partial Public Class _Default Inherits System.Web.UI.Page Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Protected Sub Page_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length)

    Read the article

  • Anyone can explain to me document.cookie

    - by dramasea
    I founs this code in w3schoool javascript coookie section, which is to read the cookie: function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } In this line: if (document.cookie.length>0) what mean document.cookie.length? In this line: c_start=document.cookie.indexOf(c_name + "="); why i need to add '=' after the c_name(cookie name) In this line: c_start=c_start + c_name.length+1; why I need to add c_name.length+1 ? What the purpose? And what the meaning of this line: if (c_end==-1) c_end=document.cookie.length; Can Anyone answer my question?Thanks!!!

    Read the article

  • Why is my program getting slower and slower ?

    - by RedWolf
    I'm using the program to send data from database to the Excel file . It works fine at the beginning and then becomes more and more slowly,finally it run out of the memory and the following error ocurrs: "java.lang.OutOfMemoryError: Java heap space...". The problem can be resolved by adding the jvm heap sapce.But the question is that it spends too much time to run out the program. After several minutes,it finished a loop with 4 seconds which can be finished with 0.5 seconds at the beginning . I can't found a solution to make it always run in a certain speed. Is it my code problem? Any clues on this? Here is the code: public void addAnswerRow(List<FinalUsers> finalUsersList,WritableWorkbook book){ if (finalUsersList.size() >0 ) { try { WritableSheet sheet = book.createSheet("Answer", 0); int colCount = 0; sheet.addCell(new Label(colCount++,0,"Number")); sheet.addCell(new Label(colCount++,0,"SchoolNumber")); sheet.addCell(new Label(colCount++,0,"District")); sheet.addCell(new Label(colCount++,0,"SchoolName")); sheet.setColumnView(1, 15); sheet.setColumnView(3, 25); List<Elements> elementsList = this.elementsManager.getObjectElementsByEduTypeAndQuestionnaireType(finalUsersList.get(0).getEducationType().getId(), this.getQuestionnaireByFinalUsersType(finalUsersList.get(0).getFinalUsersType().getId())); Collections.sort(elementsList, new Comparator<Elements>(){ public int compare(Elements o1, Elements o2) { for(int i=0; i< ( o1.getItemNO().length()>o2.getItemNO().length()? o2.getItemNO().length(): o1.getItemNO().length());i++){ if (CommonFun.isNumberic(o1.getItemNO().substring(0, o1.getItemNO().length()>3? 4: o1.getItemNO().length()-1)) && !CommonFun.isNumberic(o2.getItemNO().substring(0, o2.getItemNO().length()>3? 4: o2.getItemNO().length()-1))){ return 1; } if (!CommonFun.isNumberic(o1.getItemNO().substring(0, o1.getItemNO().length()>3? 4: o1.getItemNO().length()-1)) && CommonFun.isNumberic(o2.getItemNO().substring(0,o2.getItemNO().length()>3? 4:o2.getItemNO().length()-1))){ return -1; } if ( o1.getItemNO().charAt(i)!=o2.getItemNO().charAt(i) ){ return o1.getItemNO().charAt(i)-o2.getItemNO().charAt(i); } } return o1.getItemNO().length()> o2.getItemNO().length()? 1:-1; }}); for (Elements elements : elementsList){ sheet.addCell(new Label(colCount++,0,this.getTitlePre(finalUsersList.get(0).getFinalUsersType().getId(), finalUsersList.get(0).getEducationType().getId())+elements.getItemNO()+elements.getItem().getStem())); } int sheetRowCount =1; int sheetColCount =0; for(FinalUsers finalUsers : finalUsersList){ sheetColCount =0; sheet.addCell(new Label(sheetColCount++,sheetRowCount,String.valueOf(sheetRowCount))); sheet.addCell(new Label(sheetColCount++,sheetRowCount,finalUsers.getSchool().getSchoolNumber())); sheet.addCell(new Label(sheetColCount++,sheetRowCount,finalUsers.getSchool().getDistrict().getDistrictNumber().toString().trim())); sheet.addCell(new Label(sheetColCount++,sheetRowCount,finalUsers.getSchool().getName())); List<AnswerLog> answerLogList = this.answerLogManager.getAnswerLogByFinalUsers(finalUsers.getId()); Map<String,String> answerMap = new HashMap<String,String>(); for(AnswerLog answerLog :answerLogList ){ if (answerLog.getOptionsId() != null) { answerMap.put(answerLog.getElement().getItemNO(), this.getOptionsAnswer(answerLog.getOptionsId())); }else if (answerLog.getBlanks()!= null){ answerMap.put(answerLog.getElement().getItemNO(), answerLog.getBlanks()); }else{ answerMap.put(answerLog.getElement().getItemNO(), answerLog.getSubjectiveItemContent()); } } for (Elements elements : elementsList){ sheet.addCell(new Label(sheetColCount++,sheetRowCount,null==answerMap.get(elements.getItemNO())?"0":answerMap.get(elements.getItemNO()))); } sheetRowCount++; } book.write(); book.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RowsExceededException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }

    Read the article

  • How to get latitude and longitude position that stored in MySQL and use it in Android map application

    - by gunawan haruna
    I have tried to get the latitude and longitude position that was stored in MySQL. I want use the values to my Android map application. Here is my code: deskripsi.Java Button direction = (Button) findViewById (R.id.btnDir); direction.setOnClickListener(new OnClickListener(){ public void onClick(View arg0) { Intent z = getIntent(); des_lat = z.getExtras().getString("des_lat"); des_long = z.getExtras().getString("des_long"); Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?&daddr="+des_lat+","+des_long)); //("geo:37.827500,-122.481670")); startActivity(i); } }); And here is the content.Java private ListView list; int x; private String panjang[]; public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.kontent); super.initButtonSearch(); list = (ListView) findViewById(R.id.list); JSONObject jo; try { jo = new JSONObject(JsonKontent); JSONArray ja = jo.getJSONArray("result"); System.out.println("Panjang : " + ja.length()); if (ja.length() == 0) { Toast.makeText(Content.this, "Data tidak ada!", Toast.LENGTH_LONG).show(); finish(); } content_id = new String[ja.length()]; c_title = new String[ja.length()]; c_telephone = new String[ja.length()]; c_short_description = new String[ja.length()]; c_long_description = new String[ja.length()]; c_image1 = new String[ja.length()]; c_image2 = new String[ja.length()]; l_address = new String[ja.length()]; catagory_id = new String[ja.length()]; Location myLoc = new Location("sharedPreferences"); Location restLoc = new Location("restaurantTable"); l_latitude = new String[ja.length()]; l_longitude = new String[ja.length()]; c_name = new String[ja.length()]; panjang = new String[ja.length()]; for (x = 0; x < ja.length(); x++) { JSONObject joj = ja.getJSONObject(x); content_id[x] = joj.getString("content_id"); catagory_id[x] = joj.getString("catagory_id"); c_title[x] = joj.getString("c_title"); c_telephone[x] = joj.getString("c_telephone"); c_short_description[x] = joj.getString("c_short_description"); c_long_description[x] = joj.getString("c_long_description"); c_image1[x] = HTTPConnection.urlPicture + joj.getString("c_image1"); c_image2[x] = HTTPConnection.urlPicture + joj.getString("c_image2"); l_address[x] = joj.getString("l_address"); l_latitude[x] = joj.getString("l_latitude"); l_longitude[x] = joj.getString("l_longitude"); c_name[x] = joj.getString("c_name"); myLoc.setLatitude(myLatitude); myLoc.setLongitude(myLongitude); restLoc.setLatitude(Double.parseDouble(l_latitude[x])); restLoc.setLongitude(Double.parseDouble(l_longitude[x])); float f = myLoc.distanceTo(restLoc); int f_int = Math.round(f / 100); f = Float.valueOf(f_int) / 10; String dist = new DecimalFormat("#,##0.0").format(f); System.out.println("Panjang " + dist + " km"); panjang[x] = dist + " km"; } } catch (JSONException e) { Toast.makeText(Content.this, "Data yang dicari tidak ada!", Toast.LENGTH_LONG).show(); finish(); } PFCAdapter adapter = new PFCAdapter(this, c_image1, c_title, l_address, panjang); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub System.out.println("Content ID: " + Content.content_id[Deskripsi.id]); Deskripsi.id = arg2; waitDialog = ProgressDialog.show(Content.this, "Memuat", "Harap tunggu, sedang terhubung dengan server"); waitDialog.setIcon(R.drawable.iconnya); waitDialog.show(); new LihatRatingTask().execute(); } }); } class LihatRatingTask extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void... Arg0) { Deskripsi.jsonRating = HTTPConnection.openUrl(HTTPConnection.host + "lihat_rating.php?content_id=" + Content.content_id[Deskripsi.id]); Deskripsi.jsonSubCategory = HTTPConnection .openUrl(HTTPConnection.host + "sub_catagory_parameter.php?content_id=" + Content.content_id[Deskripsi.id]); RoutePath.place = HTTPConnection .LoadImageFromWeb(HTTPConnection.host + "Logo/" + image[Integer.valueOf(catagory_id[Deskripsi.id]) - 1]); Intent i = new Intent(Content.this, Deskripsi.class); i.putExtra("des_lat", l_latitude); i.putExtra("des_long", l_longitude); startActivity(i); waitDialog.dismiss(); return null; } protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); waitDialog.dismiss(); } } } The result is in destination EditText in maps application for Android "null,null" How to make it "destination_latitude, destination_longitude"? Help me please.

    Read the article

  • PHP Pass Dynamic Array name to function

    - by Brad
    How do I pass an array key to a function to pull up the right key's data? // The array <?php $var['TEST1'] = Array ( 'Description' => 'This is a Description', 'Version' => '1.11', 'fields' => Array( 'ID' => array( 'type' => 'int', 'length' =>'11', 'misc' =>'auto_increment' ), 'DATA' => array( 'type' => 'varchar', ' length' => '255' ) ); $var['TEST2'] = Array ( 'Description' =? 'This is the 2nd Description', 'Version' => '2.1', 'fields' => Array( 'ID' => array( 'type' => 'int', 'length' =>'11', 'misc' =>'auto_increment' ), 'DATA' => array( 'type' => 'varchar', ' length' => '255' ) ) // The function <?php $obj = 'TEST1'; print_r($schema[$obj]); // <-- Fives me output. But calling the function doesn't. echo buildStructure($obj); /** * @TODO to add auto_inc support */ function buildStructure($obj) { $output = ''; $primaryKey = $schema["{$obj}"]['primary key']; foreach ($schema["{$obj}"]['fields'] as $name => $tag) // #### ERROR #### Invalid argument supplied for foreach() { $type = $tag['type']; $length = $tag['length']; $default = $tag['default']; $description = $tag['description']; $length = (isset($length)) ? "({$length})" : ''; $default = ($default == NULL ) ? "NULL" : $default; $output .= "`{$name}` {$type}{$length} DEFAULT {$default} COMMENT `{$DESCRIPTION}`, "; } return $output; }

    Read the article

  • How can I change column length using HQL query?

    - by gmugmu
    I tried session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate(); but this throws org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query After a lot of googling, the recommendation is to use HQL instead of SQL query to do bulk updates. Not sure how to use HQL to accomplish this. There seems to be no decent HQL documentation for updating column length in a table. Thanks so much for the help.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >