Posts

C - differentiate between 0 and \0 in integer array -

possible duplicate: nul terminating int array i'm trying print out elements in array: int numbers[100] = {10, 9, 0, 3, 4}; printarray(numbers); using function: void printarray(int array[]) { int i=0; while(array[i]!='\0') { printf("%d ", array[i]); i++; } printf("\n"); } the problem of course c doesn't differentiate between 0 element in array , end of array, after it's 0 (also notated \0). i'm aware there's no difference grammatically between 0 , \0 looking way or hack achieve this: 10 9 0 3 4 instead of this 10 9 the array this: {0, 0, 0, 0} of course output still needs 0 0 0 0. any ideas? don't terminate array value in array. you need find unique terminator. since didn't indicate negative numbers in array, recommend terminating -1 : int numbers[100] = {10, 9, 0, 3, 4, -1}; if doesn't work, consider: int_max , or int_min . as last resor...

authentication - CakePHP auth and validation -

i have app uses auth component. logedin members can alter data long have no validation rules in users model. when add array $validate in model logedin users cannot submit data database. i use 1 mysql table named users. in other words works don't have validation in signup view <?php class user extends appmodel { var $name = 'user'; ?> but when add validation this: <?php class user extends appmodel { var $name = 'user'; var $validate = array( 'email' => array( 'email' => array('rule' => 'email','required'=>true,'message' => 'enter proper mail') ) ); } ?> validation in signup view works users in secret area cannot enter data database. my guess is: happening because have set required true . this enforces rule when submitted data of user model, email key needs set. therefore, works in sign form has email key. on other hand, form you're using in se...

Pulling in photos via Facebook Graph API -

i'm trying pull in tagged photos of current logged in profile. got session id appears it's empty array. <?php $photos = $facebook->api('me/photos'); $number_of_photos = count($photos[data]); ?> <?php ($i=0; $i < $number_of_photos; $i++) :?> <img src="https://graph.facebook.com/me/photos/<?php echo $photos[data][$i][url]; ?>"/> <?php endfor; ?> i'm aware code awful, i'm new php , trying few things. as stated documentation available here (scroll down 'connections'), in order user's photos must have explicitly given 1 of following permissions: user_photo_video_tags friend_photo_video_tags user_photos friend_photos permissions

html - CSS: Sidebar with folded header ribbon -

Image
now i've see various ways accomplish effect: i used accomplish table, i've since decided not use tables that. what's best way this? keeping in mind there's right border... <style> .left{ float:left; } .ribbontitle{ background:transparent url(/images/solid.png) repeat-x; height:20px; width:auto; } .ribbonend{ background:transparent url(/images/end.png) no-repeat; height:20px; width:10px; } .clear{ clear:both; } </style> <div class='left ribbontitle'>title</div> <div class='left ribbonend'>&nbsp;</div> <br class='clear'/> take 2 elements, float them left abutted each other. set repeating background of ribbon without end in div 1. set non-repeating background of ribbon "end" in other div

objective c - Cannot understand getter/setter with object -

it easy understand concept of setter/getter simple data, nsinteger example. if say: nsinteger a; the setter "a" changes value of a, , getter gets (returns) value. easy understand atomic/nonantomic concept since atomic guarantee reading "a" when being chnaged return whole value (getter , setter synchronized). but not understand setter , getter properties pointers objects (nsdata*, nsstring* example). let's example nsmutabledata: if say: nsmutabledata *m_my_mutable; imagine have setter setmymutable , getmymutable property belongs object myobject. if this, call getter (since object before appending data): [[myobject getmymutable] appenddata....] but appendingdata modify it, sould not seen setter action instead ? or setter refer fact of initiliazing value (which can retained example). there must missing in concept. thanks apple92 a setter sets value of property. when set integer property, new integer value stored. when set object prope...

open source - Windows share indexing -

i'd index windows share workgroup of win7 clients using open-source technologies. users should able run full-text queries against contents of .doc, .xls, .ppt, .pdf, .txt, .rtf, etc. files added through unc path via drag-n-drop, no need manually trigger index update. what's software stack this? trying not use win indexing here. there various open source tools indexing documents, tend require tuning. i'd recommend at: solr lucene lucene.net although solr uses java, can run on windows . in cases need trigger indexing process or schedule it. might able use filesystemwatcher .net trigger indexing of new files depends on how need visible in search results.

generics - Data.Data -- producing dataCast1 for an arity 2 type constructor (partially specialized) -

so data.map has datacast2 defined, makes sense, has arity 2 type constructor. datacast1 defaults const nothing . datacast2 defined gcast2 . for reference: class typeable => data datacast1 :: typeable1 t => (forall d. data d => c (t d)) -> maybe (c a) datacast2 :: typeable2 t => (forall d e. (data d, data e) => c (t d e)) -> maybe (c a) ... gcast1 :: (typeable1 t, typeable1 t') => c (t a) -> maybe (c (t' a)) gcast2 :: (typeable2 t, typeable2 t') => c (t b) -> maybe (c (t' b)) the question @ hand this: given in data.data , data.typeable , etc., , given arity 2 type constructor datacast2 defined (say, map , or (,) ), possible write version of datacast1 right thing partial specialization of type constructor, either 1 specific constructor @ time, or in general? intuitively, think there should solution, first few tries crashed , burned. i'm not sure if want, might steer in right direction if it's...